.pageContainer {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.mainContent {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 1rem;
  position: relative;
  overflow: visible;
}

.mainContent::-webkit-scrollbar {
  width: 8px;
}

.mainContent::-webkit-scrollbar-track {
  background: rgb(var(--color-border-50));
  border-radius: 4px;
}

.mainContent::-webkit-scrollbar-thumb {
  background: rgb(var(--color-border-200));
  border-radius: 4px;
}

.mainContent::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--color-border-300));
}

.contentWrapper {
  display: flex;
  flex: 1;
  overflow: visible;
  gap: 1rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  min-height: 0; /* Allow flex children to shrink */
}

.contentWrapper::-webkit-scrollbar {
  height: 8px;
  display: block;
}

.contentWrapper::-webkit-scrollbar-track {
  background: rgb(var(--color-border-50));
  border-radius: 4px;
}

.contentWrapper::-webkit-scrollbar-thumb {
  background: rgb(var(--color-border-200));
  border-radius: 4px;
}

.contentWrapper::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--color-border-300));
}

/* Phases panel container with toggle */
.phasesContainer {
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  height: calc(100dvh - 2rem);
  max-height: calc(100dvh - 2rem);
  min-height: 0;
  display: flex;
  flex-direction: row;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@supports not (height: 100dvh) {
  .phasesContainer {
    height: calc(100vh - 2rem);
    max-height: calc(100vh - 2rem);
  }
}

.phasesContainerExpanded {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  flex-shrink: 0;
}

.phasesContainerCollapsed {
  min-width: 32px;
  max-width: 32px;
  flex: 0 0 32px;
  /* Override sticky/flex-start from base — stretch full height so the button can be sticky inside */
  align-self: stretch;
  position: relative;
  max-height: none;
}

/* Toggle button for phases panel */
.phasesPanelToggle {
  position: absolute;
  top: 12px;
  right: -12px;
  z-index: 10;
}

.phasesContainerCollapsed .phasesPanelToggle {
  /* Switch from absolute to sticky so the button stays visible on scroll */
  position: sticky;
  top: 1rem;
  right: auto;
  margin-left: auto;
  transform: translateX(12px);
}

/* Phases panel (the white card) */
.phasesPanel {
  background-color: rgb(var(--color-card));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  overscroll-behavior: contain;
}

/* Fixed header section */
.phasesPanelHeader {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid rgb(var(--color-border-100));
}

/* Scrollable phases list area */
.phasesScrollArea {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 1rem 1rem 1rem;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Scrollbar styling for phases scroll area */
.phasesScrollArea {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--color-border-200)) transparent;
}

.phasesScrollArea::-webkit-scrollbar {
  width: 6px;
}

.phasesScrollArea::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.phasesScrollArea::-webkit-scrollbar-thumb {
  background: rgb(var(--color-border-200));
  border-radius: 3px;
}

.phasesScrollArea::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--color-border-300));
}

.phaseEditActions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgb(var(--color-border-100));
  flex-shrink: 0;
}

.phasesList {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Let the inner phasesScrollArea handle scrolling */
  overscroll-behavior: contain;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.phasesListVisible {
  opacity: 1;
  transform: translateX(0);
}

.phasesListHidden {
  opacity: 0;
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
  max-width: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

/* Wrapper for header + scrollable kanban content */
.kanbanArea {
  flex: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow it to shrink */
  overflow: visible;
}

.kanbanHeader {
  background-color: rgb(var(--color-card));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem 0.125rem;
  margin-bottom: 0.25rem;
}

.kanbanHeaderPinned {
  position: sticky;
  top: 0;
  z-index: 30;
}

/* Independent sticky status strip — sits between header and kanban content */
.kanbanStatusStripSticky {
  position: sticky;
  z-index: 29; /* below header (z-index: 30) */
  background-color: rgb(var(--color-card));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem 0.25rem;
  margin-bottom: 0.25rem;
}

.kanbanStatusStripScroller {
  overflow-x: auto;
  overflow-y: hidden;
  /* Keep near-column alignment with a subtle 2px inset from header edges. */
  margin: 0 calc(-0.75rem + 2px);
  scrollbar-width: none;
}

.kanbanStatusStripScroller::-webkit-scrollbar {
  display: none;
}

.kanbanStatusStripTrack {
  display: flex;
  gap: 1rem;
  min-width: min-content;
}

.kanbanStatusStripItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgb(var(--color-border-200));
  background: rgb(var(--color-background-50));
  color: rgb(var(--color-text-700));
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(1px);
}

.kanbanStatusStripName {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanbanStatusStripCount {
  flex-shrink: 0;
  min-width: 1.5rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Always-visible custom horizontal scrollbar for the kanban board */
.kanbanScrollbarShell {
  margin: -0.1rem -0.75rem 0;
  padding: 0.2rem 0.75rem 0.05rem;
}

.kanbanScrollbarTrack {
  position: relative;
  height: 4px;
  border-radius: 9999px;
  background: rgb(var(--color-border-100) / 0.45);
  cursor: pointer;
}

.kanbanScrollbarThumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: inherit;
  background: rgb(var(--color-border-300) / 0.9);
  cursor: grab;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  touch-action: none;
}

.kanbanScrollbarThumb:hover {
  background: rgb(var(--color-border-400) / 0.95);
}

.kanbanScrollbarThumb:focus-visible {
  outline: 2px solid rgb(var(--color-primary-500));
  outline-offset: 2px;
  background: rgb(var(--color-border-400) / 0.95);
}

.kanbanScrollbarThumb:active {
  cursor: grabbing;
}

.kanbanScrollbarThumbStatic {
  background: rgb(var(--color-border-200) / 0.7);
  pointer-events: none;
}

.kanbanContainer {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow it to shrink */
  overflow: auto;
  /* Hide the native scrollbar - using the custom track in the header instead */
  scrollbar-width: none; /* Firefox */
  cursor: grab;
}

.kanbanContainer::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Edge */
}


.kanbanBoard {
  display: flex;
  flex: 1 0 auto;
  gap: 1rem;
  min-width: min-content;
  padding-bottom: 0.5rem; /* Space for scrollbar */
}

.kanbanColumn {
  display: flex;
  flex-direction: column;
  width: 350px; /* Fixed width for equal columns */
  min-width: 350px; /* Ensure minimum width */
  max-width: 350px; /* Prevent columns from growing */
  flex-shrink: 0; /* Prevent columns from shrinking */
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.revealedHiddenColumn {
  border-style: dashed !important;
  opacity: 0.78;
}

.revealedHiddenHeader {
  filter: saturate(0.45);
  opacity: 0.82;
}

.kanbanTasks {
  padding: 8px;
  flex: 1 0 auto; /* Grow to fill stretched columns, but never shrink below content */
  border-radius: 4px;
}

.kanbanWrapper {
  flex: 1 0 auto;
  padding: 1px;
  position: relative;
}

.statusBadge {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

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

.taskCount {
  background-color: rgb(var(--color-card) / 0.8);
  color: rgb(var(--color-text-700));
  border-radius: 9999px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  position: relative;
  z-index: 1;
}

/* Global scroll zones */
.mainContent::before,
.mainContent::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  height: 30vh;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}

.mainContent::before {
  top: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.12) 0%,
    rgba(0,0,0,0.12) 70%,
    transparent 100%
  );
}

.mainContent::after {
  bottom: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.12) 0%,
    rgba(0,0,0,0.12) 70%,
    transparent 100%
  );
}

body.dragging-task .mainContent::before,
body.dragging-task .mainContent::after {
  opacity: 1;
  pointer-events: auto;
}

/* Task movement animations */

/* Task card transitions */
.taskCard {
  transition:
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease,
    opacity 0.12s ease,
    transform 0.12s ease;
  position: relative;
}

.taskCard.dragging {
  opacity: 0.35;
  cursor: grabbing;
  transition: opacity 0.1s ease;
}

/* Drop placeholder that appears between tasks */
.dropPlaceholder {
  height: 0;
  margin: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px dashed transparent;
  border-radius: 8px;
  overflow: hidden;
  background-color: transparent;
}

.dropPlaceholder.visible {
  height: 80px;
  margin: 8px 0;
  opacity: 1;
  border-color: rgb(147, 51, 234);
  background-color: rgba(147, 51, 234, 0.05);
}

/*
 * Slim drop indicator for the kanban board.
 *
 * Unlike .dropPlaceholder (which reserves a full card-sized gap), this is
 * absolutely positioned and consumes NO layout space. Inserting/removing it
 * never reflows the surrounding cards, which is what previously created a
 * hover -> reflow -> re-measure feedback loop and made the drop target flicker
 * back and forth while dragging between columns.
 *
 * It is positioned (via an inline top/bottom offset) in the centre of the gap
 * between two cards, so the "after card A" and "before card B" indicators land
 * on the exact same pixel and there is no visible jump if the closest-card
 * calculation switches between two adjacent cards.
 */
.dropIndicator {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 3px;
  border-radius: 9999px;
  background-color: rgb(147, 51, 234);
  box-shadow: 0 0 0 1px rgba(147, 51, 234, 0.25), 0 0 8px rgba(147, 51, 234, 0.45);
  z-index: 5;
  pointer-events: none;
}

/* Phase drop placeholder - styled like task drop placeholder */
.phaseDropPlaceholder {
  height: 0;
  margin: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px dashed transparent;
  border-radius: 8px;
  overflow: hidden;
  background-color: transparent;
  position: relative; /* Keep position relative if needed for other interactions, or remove if not */
}

.phaseDropPlaceholder.visible {
  height: 50px; /* Adjusted height for phases */
  margin: 8px 0;
  opacity: 1;
  border-color: rgb(147, 51, 234); /* purple */
  background-color: rgba(147, 51, 234, 0.05); /* light purple */
  /* transform: scaleY(1); Remove or ensure it doesn't conflict */
}

/* Task list container for smooth reordering */
.taskList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

/* Entry animation for newly dropped tasks */
@keyframes taskEntry {
  0% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
  }
}

.taskCard.entering {
  animation: taskEntry 0.16s ease-out;
}

/* Subtle bounce for nearby tasks when dropping */
@keyframes subtleBounce {
  0%, 100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-2px);
  }
  75% {
    transform: translateY(2px);
  }
}

.taskCard.bounce {
  animation: subtleBounce 0.5s ease-out;
}

/* Hover lift effect */
.taskCard:hover:not(.dragging) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: grab;
}

:global(body.dragging-task) .taskCard:hover:not(.dragging) {
  transform: none;
  cursor: grabbing;
}

/* Status column highlight during drag */
.kanbanColumn.dragOver {
  box-shadow: inset 0 0 0 2px rgba(147, 51, 234, 0.3), 0 0 0 1px rgba(147, 51, 234, 0.15);
}

/* Loading state for async operations */
.taskCard.loading {
  opacity: 0.6;
  pointer-events: none;
}

.taskCard.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Phase drag and drop animations */
.phaseItem {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: grab;
  position: relative;
}

.phaseItem:active {
  cursor: grabbing;
}

.phaseItem.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  transition: all 0.2s ease-out;
}

.phaseItem.dragOver {
  transform: scale(1.01);
  box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.3);
}

/* When dragging a task over a phase (not reordering) */
.phaseItem.taskDragOver {
  background-color: rgba(147, 51, 234, 0.1);
  box-shadow: inset 0 0 0 2px rgba(147, 51, 234, 0.3);
  transform: none;
}

/* Phase entry animation - same as tasks */
@keyframes phaseEntry {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(-10px);
  }
  50% {
    transform: scale(1.02) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.phaseItem.entering {
  animation: phaseEntry 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
