:root {
  /* =========================== */
  /* COLOR SYSTEM                */
  /* =========================== */

  /* Background Colors - Dark Theme */
  --color-bg-page: #1a1a1a;           /* Main page background */
  --color-bg-app: #2d2d2d;            /* App container background */
  --color-bg-card: #333333;           /* Card/content background */
  --color-bg-card-hover: #3a3a3a;     /* Card hover state */
  --color-bg-surface: #363636;        /* Elevated surface (categories) */
  --color-bg-header: #404040;         /* Header backgrounds */
  --color-bg-header-hover: #505050;   /* Header hover state */
  --color-bg-input: #2a2a2a;          /* Input field backgrounds */

  /* Text Colors */
  --color-text-primary: #f5f5f5;      /* Primary text (headings) */
  --color-text-secondary: #e0e0e0;    /* Secondary text (body) */
  --color-text-tertiary: #b0b0b0;     /* Tertiary text (icons, hints) */
  --color-text-muted: #888888;        /* Muted text (metadata) */
  --color-text-on-card: #f0f0f0;      /* Text on card backgrounds */

  /* Border Colors */
  --color-border-default: #404040;    /* Default borders */
  --color-border-light: #505050;      /* Lighter borders */
  --color-border-dark: #2a2a2a;       /* Darker borders */
  --color-border-drag: #808080;       /* Drag indicator borders */

  /* Accent Colors */
  --color-accent-primary: #4a7ba7;    /* Primary accent (links, highlights) */
  --color-accent-primary-hover: #5a8bc7; /* Primary accent hover */
  --color-link: #4a9eff;              /* Link color */
  --color-link-hover: #6eb5ff;        /* Link hover */
  --color-link-active: #3a8eef;       /* Link active/pressed */

  /* Status Colors */
  --color-error: #ff4d4d;             /* Error/delete states */
  --color-error-dark: #ff0000;        /* Error dark variant */
  --color-success: #4caf50;           /* Success states */
  --color-warning: #ff9800;           /* Warning states */

  /* Priority Colors */
  --color-priority-high: #f44336;     /* High priority */
  --color-priority-medium: #ff9800;   /* Medium priority */
  --color-priority-low: #4caf50;      /* Low priority */

  /* =========================== */
  /* BORDER RADIUS               */
  /* =========================== */
  --radius-sm: 4px;                   /* Small elements (badges, chips) */
  --radius-md: 6px;                   /* Medium elements (cards, categories) */
  --radius-lg: 8px;                   /* Large elements (modals, app container) */
  --radius-xl: 12px;                  /* Extra large (sheets, drawers) */
  --radius-full: 9999px;              /* Fully rounded (pills, circles) */

  /* =========================== */
  /* BOX SHADOWS                 */
  /* =========================== */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.4);
  --shadow-app: 0 0 10px rgba(0, 0, 0, 0.3);

  /* =========================== */
  /* COMPONENT SIZING            */
  /* =========================== */
  --width-category-min: 280px;        /* Minimum category width */
  --width-category-max: 600px;        /* Maximum category width */
  --width-collapsed-category: 250px;  /* Collapsed category width */
  --width-search-mobile: 250px;       /* Mobile search input width */
  --width-search-small: 200px;        /* Small mobile search width */

  /* =========================== */
  /* TOUCH TARGETS               */
  /* =========================== */
  /* Mobile Accessibility (WCAG 2.1 AAA, iOS HIG, Material Design) */
  /* All interactive elements should use --touch-target-medium (44px) or larger */
  /* Apple iOS: 44x44pt minimum | Android: 48x48dp minimum | WCAG AAA: 44x44px */
  --touch-target-large: 48px;
  --touch-target-medium: 44px;
  --touch-target-small: 40px;

  /* =========================== */
  /* SPACING SCALE               */
  /* =========================== */
  --spacing-xs: 4px;    /* Tight spacing within components */
  --spacing-sm: 8px;    /* Close related items */
  --spacing-md: 16px;   /* Default spacing between components */
  --spacing-lg: 24px;   /* Section spacing */
  --spacing-xl: 32px;   /* Major section breaks */
  --spacing-2xl: 48px;  /* Page-level spacing */

  /* Legacy spacing variables - mapped to new system for backwards compatibility */
  --spacing-card: var(--spacing-md);
  --spacing-card-gap: var(--spacing-sm);
  --spacing-screen-edge: var(--spacing-md);

  /* =========================== */
  /* TYPOGRAPHY                  */
  /* =========================== */
  --font-size-body: 16px;
  --font-size-header: 18px;
  --font-size-small: 14px;
  --font-size-badge: 12px;
  --font-size-icon: 20px;
  --font-size-icon-sm: 18px;
  --font-size-icon-md: 16px;

  /* Line Heights */
  --line-height-body: 1.5;
  --line-height-header: 1.2;
  --line-height-tight: 1.3;

  /* =========================== */
  /* ANIMATION                   */
  /* =========================== */
  --transition-fast: 150ms;
  --transition-medium: 250ms;
  --transition-slow: 350ms;
  --easing-enter: cubic-bezier(0.2, 0, 0, 1);
  --easing-exit: cubic-bezier(0.4, 0, 1, 1);

  /* =========================== */
  /* Z-INDEX LAYERS              */
  /* =========================== */
  --z-card: 1;
  --z-menu: 100;
  --z-drawer: 200;
  --z-backdrop: 199;
  --z-toast: 300;
}

/* Ensure hidden attribute always hides elements */
[hidden] {
    display: none !important;
}

body {
    font-family: Arial, sans-serif;
    margin: 0 auto;
    padding: var(--spacing-md);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    background-color: var(--color-bg-page);
    color: var(--color-text-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    background-color: var(--color-bg-app);
    box-shadow: var(--shadow-app);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding: 0;
}

.controls {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.icon-btn {
    background-color: var(--color-bg-header);
    border: none;
    border-radius: var(--radius-lg);
    min-width: var(--touch-target-large);
    min-height: var(--touch-target-large);
    padding: var(--spacing-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-secondary);
    font-size: var(--font-size-icon);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover,
.icon-btn:active {
    background-color: var(--color-bg-header-hover);
    transform: scale(1.05);
}

/* Header Search Container */
.header-search-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* Mobile specific adjustments */
@media (max-width: 600px) {
    .app-header {
        padding: 0;
    }

    .controls {
        gap: var(--spacing-sm);
    }

    .icon-btn {
        font-size: 18px;
        padding: var(--spacing-sm);
    }

    /* Mobile search adjustments */
    .search-input-wrapper:not([hidden]) {
        max-width: 250px;
    }

    .search-input {
        width: 250px;
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .search-input-wrapper:not([hidden]) {
        max-width: 200px;
    }

    .search-input {
        width: 200px;
        font-size: 14px;
        padding: 10px 36px 10px 40px;
    }

    .search-toggle-btn {
        min-width: var(--touch-target-medium);
        min-height: var(--touch-target-medium);
        padding: 10px;
        font-size: 18px;
    }
}

h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-header);
    font-weight: 600;
    color: var(--color-text-primary);
}

h1 {
    margin: 0;
    font-size: var(--font-size-header);
}

#categoriesContainer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    justify-content: center;
    padding-top: var(--spacing-md);
}

.collapsed-categories-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-width: var(--width-collapsed-category);
    flex: 0 0 var(--width-collapsed-category);
    max-width: var(--width-collapsed-category);
}

.category {
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background-color: var(--color-bg-surface);
    box-shadow: var(--shadow-md);
    min-width: var(--width-category-min);
    flex: 1 1 auto; /* Allow dynamic sizing based on content */
    max-width: var(--width-category-max); /* Increased max width for content-heavy columns */
}

.category.collapsed-category {
    min-width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
}

.category.collapsed-category .category-header {
    padding: var(--spacing-sm);
    min-height: auto;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--color-bg-header);
    border-bottom: 1px solid var(--color-border-light);
    cursor: move;
    user-select: none;
    gap: var(--spacing-sm);
    min-height: var(--touch-target-medium);
}

.category-header span {
    font-weight: bold;
    color: var(--color-text-primary);
    pointer-events: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* Allow flex item to shrink below content size */
}

.category-menu {
    color: var(--color-text-tertiary);
    font-size: var(--font-size-icon-sm);
    pointer-events: auto;
    cursor: pointer !important;
    padding: var(--spacing-sm);
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.2s ease;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    position: relative;
    z-index: 1;
}

.category-header:hover .category-menu {
    opacity: 1;
}

.category-menu:hover {
    color: var(--color-text-secondary);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Make category menu always visible on mobile/touch devices */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .category-menu {
        opacity: 1;
    }
}

.category-header.dragging {
    opacity: 0.5;
    background-color: var(--color-bg-header-hover);
}

.category-actions {
    display: flex;
    gap: var(--spacing-sm);
    pointer-events: auto;
    position: relative;
    z-index: 10;
    cursor: default; /* Override parent's move cursor */
    flex-shrink: 0; /* Prevent actions from shrinking on mobile */
}

.category-actions * {
    cursor: pointer !important; /* Ensure all children show pointer cursor */
}

.todos-container {
    padding: var(--spacing-sm);
    min-height: var(--touch-target-small); /* Ensure there's always a drop zone */
    background-color: var(--color-bg-card); /* Slightly lighter background for better visual separation */
}

/* Per-Category Filter Pills */
.category-filters {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border-default);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.cat-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-full);
    color: var(--color-text-tertiary);
    font-size: var(--font-size-badge);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    line-height: 1.4;
}

.cat-filter-pill.active {
    background: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
    color: #ffffff;
}

.cat-filter-pill:hover:not(.active) {
    background: var(--color-bg-card-hover);
    color: var(--color-text-secondary);
}

.collapsed-category .category-filters {
    display: none;
}

/* Quick Add Input */
.quick-add-wrapper {
    padding: var(--spacing-xs) 0;
    border-top: 1px solid var(--color-border-default);
    margin-top: var(--spacing-xs);
}

.quick-add-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-small);
    outline: none;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
}

.quick-add-input::placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

.quick-add-input:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 2px rgba(74, 123, 167, 0.25);
}

.collapsed-category .quick-add-wrapper {
    display: none;
}

/* Todo Card - Mobile-First Collapsed Structure */
.todo-card {
    position: relative;
    border-bottom: 1px solid var(--color-border-default);
    transition: background-color 0.3s ease;
    color: var(--color-text-on-card);
    overflow: hidden;
}

.todo-card:last-child {
    border-bottom: none;
}

.todo-card:hover {
    cursor: pointer;
}

/* Card content wrapper - slides over swipe indicators */
.todo-card-content {
    position: relative;
    background-color: var(--color-bg-card);
    z-index: 1;
    transition: transform 0.3s ease-out;
}

.todo-card:hover .todo-card-content {
    background-color: var(--color-bg-card-hover);
}

.todo-card.completed {
    opacity: 0.6;
}

.todo-card.completed .todo-text {
    text-decoration: line-through;
}

/* Card Header - Flex Container */
.todo-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-card-gap);
    padding: var(--spacing-card);
}

/* Checkbox with Touch Target */
.todo-checkbox {
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.todo-checkbox input[type="checkbox"] {
    width: var(--touch-target-medium);
    height: var(--touch-target-medium);
    cursor: pointer;
    margin: 0;
}

/* Text Container with Truncation */
.todo-text-container {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    max-width: calc(100% - 120px);
}

.todo-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    font-size: var(--font-size-body);
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Expanded state - full text visible in collapsed header */
.todo-card[data-expanded="true"] .todo-text {
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* WS1: Expanded Content Area */
.todo-card-expanded {
    display: none;
}

.todo-card[data-expanded="true"] .todo-card-expanded {
    display: block;
    animation: expandCard var(--transition-medium) var(--easing-enter);
}

/* Full text display in expanded state */
.todo-text-full {
    padding: var(--spacing-card);
    padding-top: 0;
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    color: var(--color-text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* WS1 S4-1: Metadata Section */
.todo-metadata {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border-dark);
    margin-bottom: var(--spacing-sm);
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-small);
    color: var(--color-text-muted);
}

.metadata-icon {
    font-size: var(--font-size-icon-md);
    flex-shrink: 0;
}

.metadata-text {
    line-height: 1.4;
}

.metadata-link {
    color: var(--color-link);
    text-decoration: none;
    line-height: 1.4;
    word-break: break-all;
    transition: color 0.2s ease;
}

.metadata-link:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

.metadata-link:active {
    color: var(--color-link-active);
}

/* Priority Badge */
.todo-card .priority-badge {
    flex-shrink: 0;
}

/* Menu Icon with Touch Target */
.menu-icon {
    min-width: var(--touch-target-large);
    min-height: var(--touch-target-large);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-icon);
    padding: 0;
    transition: all 0.3s ease;
    border-radius: var(--radius-sm);
}

.menu-icon:hover {
    background-color: rgba(176, 176, 176, 0.2);
    color: var(--color-text-secondary);
}

/* Legacy support - keep old class name for compatibility */
.todo-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-card-gap);
    padding: var(--spacing-card);
    border-bottom: 1px solid var(--color-border-default);
    transition: background-color 0.3s ease;
    color: var(--color-text-on-card);
}

.todo-item:last-child {
    border-bottom: none;
}

.todo-item:hover {
    background-color: var(--color-bg-card-hover);
    cursor: pointer;
    border-left: 3px solid var(--color-accent-primary);
    padding-left: 7px;
}

.todo-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.todo-item input[type="checkbox"] {
    margin-right: 10px;
    width: var(--touch-target-medium);
    height: var(--touch-target-medium);
    flex-shrink: 0;
    cursor: pointer;
}

.todo-item span {
    flex-grow: 1;
}

.todo-item button {
    background-color: transparent;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    transition: color 0.3s ease;
}

.todo-item button:hover {
    color: var(--color-error-dark);
}

#error-display {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-error);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
    display: none;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Drag and Drop Styles */
.todo-item[draggable="true"],
.todo-card[draggable="true"] {
    cursor: default; /* Let individual elements control cursor */
}

.category-header[draggable="true"] {
    cursor: move;
}

.todo-item[draggable="true"]:hover,
.todo-card[draggable="true"]:hover,
.category-header[draggable="true"]:hover {
    background-color: #404040;
}

/* Style for items being dragged */
.todo-item.dragging,
.todo-card.dragging,
.category-header.dragging {
    opacity: 0.5;
    background-color: var(--color-bg-header-hover);
}

/* Style for drop targets */
.category.drag-over {
    border: 2px dashed #808080;
    background-color: #404040;
    position: relative;
}

/* Add visual indicator for category drop position */
.category.drag-over::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 3px;
    background-color: #808080;
    border-radius: 2px;
}

/* Style for todo item when it's a valid drop target */
.todo-item.drag-over,
.todo-card.drag-over {
    border-top: 2px solid #808080;
    background-color: #404040;
    position: relative;
}

/* Add a visual indicator for the drop position */
.todo-item.drag-over::before,
.todo-card.drag-over::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #808080;
}

.input-sections {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding: 0;
}

/* Mobile-Optimized Input Area */
.input-area {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.input-toggle {
    width: var(--touch-target-large);
    height: var(--touch-target-large);
    background: #4a7ba7;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
    align-self: flex-start;
}

.input-toggle:hover,
.input-toggle:active {
    background: #5a8bc7;
    transform: scale(1.05);
}

.input-fields {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 12px;
    padding: var(--spacing-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.input-fields[hidden] {
    display: none;
}

.input-todo-text {
    width: 100%;
    height: var(--touch-target-large);
    padding: var(--spacing-sm);
    font-size: var(--font-size-body);
    background: #363636;
    border: 1px solid #404040;
    border-radius: 8px;
    color: #e0e0e0;
}

.input-todo-text:focus-visible {
    outline: none;
    border-color: #4a7ba7;
    box-shadow: 0 0 0 2px rgba(74, 123, 167, 0.2);
}

.input-todo-text::placeholder {
    color: #666;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--spacing-sm);
}

.input-priority {
    height: var(--touch-target-large);
    padding: var(--spacing-sm);
    font-size: var(--font-size-body);
    background: #363636;
    border: 1px solid #404040;
    border-radius: 8px;
    color: #e0e0e0;
    cursor: pointer;
}

.input-priority:focus-visible {
    outline: none;
    border-color: #4a7ba7;
    box-shadow: 0 0 0 2px rgba(74, 123, 167, 0.2);
}

.input-add-button {
    min-width: var(--touch-target-large);
    height: var(--touch-target-large);
    padding: 0 24px;
    background: #4a7ba7;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.input-add-button:hover,
.input-add-button:active {
    background: #5a8bc7;
}

.input-add-button-full {
    width: 100%;
    grid-column: 1 / -1;
}

/* Search and Filter Section */
/* Header-based Search Styles */
.search-toggle-btn {
    min-width: var(--touch-target-large);
    min-height: var(--touch-target-large);
    background: #4a7ba7;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-toggle-btn:hover,
.search-toggle-btn:active {
    background: #5a8bc7;
    transform: scale(1.05);
}

.search-input-wrapper {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    align-items: center;
    background: #2d2d2d;
    border-radius: 8px;
    padding-right: 0;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transition: max-width 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    z-index: 100;
}

.search-input-wrapper:not([hidden]) {
    max-width: 300px;
    opacity: 1;
    padding-right: var(--spacing-sm);
}

.search-input {
    width: 300px;
    height: var(--touch-target-large);
    padding: var(--spacing-sm) 40px var(--spacing-sm) 44px; /* Space for icons */
    font-size: var(--font-size-body); /* 16px - prevents zoom */
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #e0e0e0;
    transition: border-color var(--transition-fast);
}

.search-input:focus-visible {
    outline: none;
    border-color: #4a7ba7;
    box-shadow: 0 0 0 2px rgba(74, 123, 167, 0.2);
}

.search-input::placeholder {
    color: #666;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #888;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition-fast);
}

.search-clear:hover,
.search-clear:active {
    background: #3a3a3a;
    color: #e0e0e0;
}

/* Remove default search cancel button */
.search-input::-webkit-search-cancel-button {
    display: none;
}

/* Filter Section */
.filter-section {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-screen-edge);
    background-color: #363636;
    border-radius: 6px;
    border: 1px solid #404040;
}

.filter-container {
    position: relative;
    display: flex;
    align-items: center;
}

.filter-pills {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    scroll-behavior: smooth;
}

.filter-pills::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--touch-target-medium);
    padding: 8px 12px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 22px;
    color: #e0e0e0;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    scroll-snap-align: start;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.filter-pill.active {
    background: #4a7ba7;
    border-color: #5a8bc7;
    color: #ffffff;
}

.filter-pill:hover:not(.active) {
    background: #3a3a3a;
}

.filter-icon {
    font-size: 16px;
}

/* Arrow buttons */
.filter-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: var(--touch-target-medium);
    height: var(--touch-target-medium);
    background: linear-gradient(90deg, #363636 70%, transparent);
    border: none;
    color: #e0e0e0;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    display: none; /* Show with JavaScript when overflow */
    align-items: center;
    justify-content: center;
}

.filter-arrow-left {
    left: 0;
}

.filter-arrow-right {
    right: 0;
    background: linear-gradient(270deg, #363636 70%, transparent);
}

.filter-container.has-overflow .filter-arrow {
    display: flex;
}

/* Legacy support - kept for backwards compatibility */
.filter-buttons {
    display: flex;
    gap: 5px;
}

.filter-btn {
    padding: 10px 12px;
    border: 1px solid #404040;
    border-radius: 4px;
    background-color: #404040;
    color: #b0b0b0;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: var(--touch-target-medium);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-btn:hover {
    background-color: #505050;
    border-color: #606060;
}

.filter-btn.active {
    background-color: #4a7ba7;
    border-color: #5a8bb7;
    color: #ffffff;
}

/* Legacy clear button - kept for backwards compatibility */
.clear-search-btn {
    padding: 10px;
    background-color: #404040;
    border: 1px solid #404040;
    border-radius: 4px;
    color: var(--color-error);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: var(--touch-target-medium);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    background-color: #505050;
    color: var(--color-error-dark);
}

.input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.input-group input {
    padding: 12px;
    border: 1px solid #404040;
    border-radius: 3px;
    background-color: #363636;
    color: #e0e0e0;
    font-size: var(--font-size-body); /* Prevents zoom on iOS */
}

.input-group input:focus-visible {
    outline: none;
    border-color: #505050;
}

#newCategory {
    width: 140px;
}

#newTodo {
    width: 160px;
}

#newTodoUrl {
    width: 130px;
}

#newTodoPriority {
    width: 80px;
}

.priority-select {
    padding: 5px 8px;
    border: 1px solid #404040;
    border-radius: 3px;
    background-color: #363636;
    color: #e0e0e0;
    font-size: 13px;
    cursor: pointer;
}

.priority-select:focus-visible {
    outline: none;
    border-color: #505050;
}

.priority-select option {
    background-color: #363636;
    color: #e0e0e0;
}

/* Priority badges - only show for HIGH and LOW to reduce visual noise (WS5) */
.priority-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: var(--font-size-badge);
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Only show badges for HIGH and LOW priorities */
.priority-high {
    background-color: var(--color-error);
    color: #ffffff;
    border: 1px solid #ff6666;
}

.priority-medium {
    display: none; /* Hide medium priority badges to reduce visual noise */
}

.priority-low {
    background-color: #4a4a4a;
    color: #b0b0b0;
    border: 1px solid #555555;
}

.icon-button {
    background-color: #404040;
    border: none;
    border-radius: 4px;
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #b0b0b0;
    font-size: 15px;
    padding: 10px;
}

.icon-button:hover {
    background-color: #505050;
    color: #e0e0e0;
}

/* Breadcrumb Navigation Styles */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Hide scrollbar */
  margin-bottom: var(--spacing-md);
}

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

.breadcrumb-item {
  font-size: var(--font-size-small);
  color: #4a7ba7;
  text-decoration: none;
  min-height: var(--touch-target-medium);
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  transition: color var(--transition-fast);
  cursor: pointer;
}

.breadcrumb-item:not(.breadcrumb-current) {
  cursor: pointer;
}

.breadcrumb-item:not(.breadcrumb-current):hover,
.breadcrumb-item:not(.breadcrumb-current):active {
  color: #5a8bc7;
  text-decoration: underline;
}

.breadcrumb-current {
  color: #e0e0e0;
  font-weight: 500;
  cursor: default;
}

.breadcrumb-separator {
  color: #666;
  font-size: 14px;
  user-select: none;
}

/* Mobile specific */
@media (max-width: 600px) {
  .breadcrumbs {
    font-size: 14px;
  }

  /* Truncate long breadcrumbs */
  .breadcrumb-item.truncated {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Tab Navigation Styles */
.tab-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid #404040;
    position: relative;
}

.tab-navigation {
    display: flex;
    gap: var(--spacing-xs);
    overflow-x: hidden;
    overflow-y: hidden;
    scroll-behavior: smooth;
    flex: 1;
    padding-bottom: 0;
}

.tab {
    background-color: #363636;
    border: 1px solid #404040;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: background-color 0.3s ease;
    color: #e0e0e0;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.tab:hover {
    background-color: #404040;
}

.tab.active {
    background-color: #2d2d2d;
    border-bottom: 2px solid #2d2d2d;
    margin-bottom: -2px;
    font-weight: bold;
}

.tab-content {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tab-menu {
    color: #b0b0b0;
    font-size: 18px;
    pointer-events: auto;
    cursor: pointer;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.2s ease;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
}

.tab:hover .tab-menu {
    opacity: 1;
}

.tab-menu:hover {
    color: #e0e0e0;
    background-color: rgba(255, 255, 255, 0.1);
}

.tab.drag-over {
    background-color: #505050;
    border-color: #808080;
}

/* Special tab styling for High Priority Dashboard */
.tab.special-tab {
    background: linear-gradient(135deg, #ff4444 0%, #cc3333 100%);
    border-color: #ff6666;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
}

.tab.special-tab:hover {
    background: linear-gradient(135deg, #ff5555 0%, #dd4444 100%);
}

.tab.special-tab.active {
    background: linear-gradient(135deg, #ff3333 0%, #bb2222 100%);
    border-bottom: 2px solid #ff3333;
    box-shadow: 0 2px 12px rgba(255, 68, 68, 0.4);
}

/* Category context styling for dashboard view */
.category-context {
    opacity: 0.7;
    font-size: 0.9em;
    font-weight: normal;
    color: #b0b0b0;
}

.tab-scroll-btn {
    background-color: #404040;
    border: none;
    border-radius: 4px;
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    padding: 10px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tab-scroll-btn:hover:not(:disabled) {
    background-color: #505050;
}

.tab-scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tab-add-btn {
    background-color: #404040;
    border: 1px solid #606060;
    border-radius: 4px;
    min-width: var(--touch-target-medium);
    min-height: var(--touch-target-medium);
    padding: 10px 16px;
    color: #b0b0b0;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tab-add-btn:hover {
    border-color: #808080;
    background-color: #505050;
    color: #e0e0e0;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #888;
    padding: 40px;
    font-style: italic;
    font-size: 16px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background-color: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: var(--spacing-lg);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-top: 0;
    color: #e0e0e0;
    margin-bottom: var(--spacing-md);
}

.modal-content p {
    color: #b0b0b0;
    margin: var(--spacing-sm) 0;
}

.tab-select {
    width: 100%;
    padding: var(--spacing-sm);
    margin: var(--spacing-md) 0;
    border: 1px solid #404040;
    border-radius: 4px;
    background-color: #363636;
    color: #e0e0e0;
    font-size: 16px;
}

.tab-select:focus-visible {
    outline: none;
    border-color: #606060;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-md);
}

.btn-primary {
    background-color: #4a7ba7;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    min-height: var(--touch-target-medium);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background-color: #5a8bb7;
}

.btn-secondary {
    background-color: #404040;
    color: #e0e0e0;
    border: 1px solid #606060;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    min-height: var(--touch-target-medium);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background-color: #505050;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background-color: #363636;
    border: 1px solid #505050;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 150px;
}

.context-menu-header {
    padding: 8px 12px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #505050;
}

.context-menu-item {
    padding: 10px 12px;
    cursor: pointer;
    color: #e0e0e0;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #404040;
}


/* Expand/Collapse Animation */
@keyframes expandCard {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* WS1 S4-2: Priority Selector */
.priority-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md) var(--spacing-sm);
}

.priority-option {
    min-height: var(--touch-target-medium);
    border: 1px solid #3a3a3a;
    background: #2a2a2a;
    color: #888;
    border-radius: 22px;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.priority-option.active {
    background: #4a7ba7;
    color: #ffffff;
    border-color: #5a8bc7;
}

.priority-option:hover:not(.active) {
    background: #3a3a3a;
    color: #e0e0e0;
}

/* Legacy todo-text styling (for old .todo-item structure) */
.todo-item .todo-text {
    flex-grow: 1;
    min-width: 0; /* Allow flex item to shrink below content size */
    word-wrap: break-word; /* Break long words */
    overflow-wrap: break-word; /* Modern alternative to word-wrap */
    word-break: break-word; /* Break words if necessary */
    white-space: normal; /* Allow text wrapping */
    line-height: 1.4; /* Better readability for wrapped text */
}

/* Todo Action Buttons */
.todo-link-button,
.todo-copy-button,
.todo-edit-button,
.todo-delete-button {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    min-width: var(--touch-target-large);
    min-height: var(--touch-target-large);
    padding: 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.todo-link-button {
    color: #6ba7e0;
}

.todo-link-button:hover {
    background-color: rgba(107, 167, 224, 0.2);
    color: #8bc5ff;
}

.todo-copy-button {
    color: #b0b0b0;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.todo-item:hover .todo-copy-button {
    opacity: 1;
}

.todo-copy-button:hover {
    background-color: rgba(176, 176, 176, 0.2);
    color: #e0e0e0;
}

.todo-edit-button {
    color: #b0b0b0;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.todo-item:hover .todo-edit-button {
    opacity: 1;
}

.todo-edit-button:hover {
    background-color: rgba(176, 176, 176, 0.2);
    color: #e0e0e0;
}

.todo-delete-button {
    color: var(--color-error);
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.todo-item:hover .todo-delete-button {
    opacity: 1;
}

.todo-delete-button:hover {
    background-color: rgba(255, 77, 77, 0.2);
    color: var(--color-error-dark);
}

/* Edit Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.2s ease-out;
}

.modal .modal-content {
    background-color: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 12px;
    padding: var(--spacing-lg);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        background-color: rgba(0, 0, 0, 0);
    }
    to {
        background-color: rgba(0, 0, 0, 0.7);
    }
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal .modal-content h2 {
    margin-top: 0;
    color: #e0e0e0;
    margin-bottom: var(--spacing-md);
    font-size: 24px;
}

.modal-field {
    margin-bottom: var(--spacing-md);
}

.modal-field label {
    display: block;
    color: #b0b0b0;
    margin-bottom: var(--spacing-xs);
    font-size: 14px;
}

.modal-field input,
.modal-field select {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid #404040;
    border-radius: 4px;
    background-color: #363636;
    color: #e0e0e0;
    font-size: 16px;
    box-sizing: border-box;
}

.modal-field input:focus-visible,
.modal-field select:focus-visible {
    outline: none;
    border-color: #4a7ba7;
    box-shadow: 0 0 0 3px rgba(74, 123, 167, 0.1);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-md);
}

.modal-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 80px;
    min-height: var(--touch-target-medium);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-button:active {
    transform: scale(0.98);
}

.cancel-button {
    background-color: #404040;
    color: #e0e0e0;
    border: 1px solid #606060;
}

.cancel-button:hover {
    background-color: #505050;
    border-color: #707070;
}

.save-button {
    background-color: #4a7ba7;
    color: white;
    box-shadow: 0 2px 8px rgba(74, 123, 167, 0.3);
}

.save-button:hover {
    background-color: #5a8bb7;
    box-shadow: 0 4px 12px rgba(74, 123, 167, 0.4);
    transform: translateY(-1px);
}

.save-button:active {
    transform: translateY(0) scale(0.98);
}

.danger-button {
    background-color: #c94a4a !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(201, 74, 74, 0.3) !important;
}

.danger-button:hover {
    background-color: #d65a5a !important;
    box-shadow: 0 4px 12px rgba(201, 74, 74, 0.4) !important;
    transform: translateY(-1px) !important;
}

.danger-button:active {
    transform: translateY(0) scale(0.98) !important;
}

/* Responsive Design - Mobile First Spacing */
@media (max-width: 600px) {
    :root {
        /* On mobile, reduce some spacing values for better space utilization */
        --spacing-md: 12px;   /* Reduce from 16px to 12px */
        --spacing-lg: 16px;   /* Reduce from 24px to 16px */
        --spacing-xl: 24px;   /* Reduce from 32px to 24px */
        --font-size-header: 18px; /* Smaller on mobile */
    }

    body {
        padding: var(--spacing-sm);
    }

    #app {
        padding: var(--spacing-sm);
    }

    #categoriesContainer {
        gap: var(--spacing-sm);
        padding-top: var(--spacing-sm);
    }

    .category {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .tab-container {
        flex-wrap: wrap;
        margin-bottom: var(--spacing-md);
    }

    .tab {
        font-size: 14px;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .modal-content {
        padding: var(--spacing-md);
    }

    .input-sections {
        flex-direction: column;
    }

    .input-group input {
        width: 100% !important;
    }

    /* Ensure input fields don't zoom on iOS - minimum 16px (WS5) */
    input[type="text"],
    textarea,
    select,
    button {
        font-size: var(--font-size-body);
    }

    /* Never allow text to be smaller than 16px on mobile (WS5) */
    body, p, span, div, input, button {
        font-size: max(16px, 1em);
    }
}

/* Larger screens can have more generous spacing */
@media (min-width: 600px) {
    /* Limit form widths on desktop to avoid taking too much space */
    .search-filter-section {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .input-sections {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Keyboard Shortcuts Help Modal */
.shortcuts-help {
    max-width: 600px;
}

.shortcuts-list {
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    background-color: #363636;
    border-radius: 4px;
    border: 1px solid #404040;
}

.shortcut-keys {
    background-color: #2d2d2d;
    border: 1px solid #505050;
    border-radius: 4px;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #8bc5ff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.shortcut-description {
    color: #e0e0e0;
    font-size: 14px;
    flex: 1;
    margin-left: 20px;
    text-align: right;
}

/* Scrollbar for shortcuts list */
.shortcuts-list::-webkit-scrollbar {
    width: 8px;
}

.shortcuts-list::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.shortcuts-list::-webkit-scrollbar-thumb {
    background: #505050;
    border-radius: 4px;
}

.shortcuts-list::-webkit-scrollbar-thumb:hover {
    background: #606060;
}

/* ========== KEYBOARD NAVIGATION STYLES (WS5, WS6) ========== */

/*
 * Focus State Implementation for Accessibility
 *
 * This section implements comprehensive keyboard navigation focus states
 * to support keyboard-only users and improve accessibility (WCAG 2.1 AA).
 *
 * Key Design Decisions:
 * 1. Uses :focus-visible instead of :focus to show focus only for keyboard navigation
 *    - Mouse clicks won't trigger focus indicators
 *    - Tab/keyboard navigation will show clear focus indicators
 *
 * 2. Consistent Focus Style:
 *    - Color: #4a7ba7 (Primary blue, matches app theme)
 *    - Outline: 2px solid
 *    - Offset: 2px (creates breathing room)
 *    - Additional box-shadow on some elements for enhanced visibility
 *
 * 3. Differentiation from Hover States:
 *    - Hover: Background color change, subtle shadow, color shift
 *    - Focus: Outline/border ring, higher contrast, persists until focus moves
 *    - Focus + Hover: Both styles combined when element is both focused AND hovered
 *
 * 4. Element Coverage:
 *    - All buttons (header, FAB, modal, input buttons)
 *    - All inputs and selects
 *    - Navigation elements (tabs, breadcrumbs, filter pills)
 *    - Interactive cards (todo items)
 *    - Checkboxes
 *    - Menu items
 *
 * Browser Compatibility:
 *    - :focus-visible is supported in modern browsers (Chrome 86+, Firefox 85+, Safari 15.4+)
 *    - Fallback: .js-focus-visible polyfill class (see end of file)
 */

/* Keyboard focus indicator for todo cards */
.todo-card {
    transition: box-shadow var(--transition-fast);
    outline: none;
    position: relative;
}

.todo-card.keyboard-focused {
    box-shadow: 0 0 0 2px #4a7ba7;
    z-index: calc(var(--z-card) + 1);
}

/* Ensure focus is visible on all interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Remove default outline, use custom */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Make todo cards focusable */
.todo-card[tabindex] {
    cursor: pointer;
}

/* Ensure keyboard focus works with hover states */
.todo-card.keyboard-focused:hover {
    box-shadow: 0 0 0 2px #5a8bb7, 0 2px 4px rgba(0,0,0,0.2);
}

/* Enhanced focus states for specific interactive elements */
/* Header icon buttons */
.icon-btn:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Input toggle buttons (FAB-style) */
.input-toggle:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 123, 167, 0.3);
}

/* Search toggle button */
.search-toggle-btn:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 123, 167, 0.3);
}

/* Filter pills */
.filter-pill:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(74, 123, 167, 0.3);
}

/* Filter scroll arrows */
.filter-arrow:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Tab navigation buttons */
.tab-scroll-btn:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

.tab-add-btn:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Tab items */
.tab-item:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Breadcrumb navigation */
.breadcrumb-item:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Modal buttons */
.modal-button:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Input add buttons */
.input-add-button:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Search clear button */
.search-clear:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Menu icon buttons */
.menu-icon:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Checkboxes - enhance native focus */
input[type="checkbox"]:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

/* Collapse/expand buttons */
.collapse-btn:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Action menu items */
.action-menu-item:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: -2px; /* Inset for menu items */
    border-radius: 4px;
}

/* ========== ACTION MENU STYLES (WS4, S2-4) ========== */

.action-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    display: flex;
    align-items: flex-end;
}

.action-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-backdrop);
    animation: fadeIn var(--transition-medium) var(--easing-enter);
}

.action-menu-drawer {
    position: relative;
    width: 100%;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    z-index: var(--z-drawer);
    animation: slideUp var(--transition-medium) var(--easing-enter);
    max-height: 80vh;
    overflow-y: auto;
    transition: transform var(--transition-fast);
}

/* Swipe handle */
.action-menu-handle {
    width: 40px;
    height: 4px;
    background: #666;
    border-radius: 2px;
    margin: 12px auto;
    cursor: grab;
}

.action-menu-items {
    padding: 0 var(--spacing-md) var(--spacing-xl);
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
    height: 56px;
    padding: 0 var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.action-menu-item:hover,
.action-menu-item:active {
    background: #2a2a2a;
}

.action-menu-item-danger {
    color: #f44336;
}

.action-menu-item-danger:hover,
.action-menu-item-danger:active {
    background: rgba(244, 67, 54, 0.1);
}

.action-menu-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.action-menu-label {
    flex: 1;
    font-weight: 500;
}

.action-menu-divider {
    height: 1px;
    background: #2a2a2a;
    margin: var(--spacing-sm) 0;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(100%);
    }
}

/* Dismissing state */
.action-menu-overlay.dismissing .action-menu-backdrop {
    animation: fadeOut var(--transition-medium) var(--easing-exit);
}

.action-menu-overlay.dismissing .action-menu-drawer {
    animation: slideDown var(--transition-medium) var(--easing-exit);
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ========== FEEDBACK MANAGER STYLES (WS4, S2-6) ========== */

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #2a2a2a;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 14px;
    transform: translateY(-100px);
    opacity: 0;
    transition: all var(--transition-medium) var(--easing-enter);
    pointer-events: auto;
}

.toast-show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: #4caf50;
}

.toast-error {
    background: #f44336;
}

.toast-info {
    background: #2196f3;
}

.toast-warning {
    background: #ff9800;
}

.toast-icon {
    font-size: 20px;
    font-weight: bold;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 600ms linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tap feedback */
.tap-feedback {
    transition: transform var(--transition-fast);
}

.tap-feedback:active {
    transform: scale(0.98);
}

/* Ripple effect (WS4, S2-5) */
.menu-icon {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 600ms ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(10);
        opacity: 0;
    }
}

/* ========== PULL-TO-REFRESH STYLES (WS2, S4-4) ========== */

.pull-to-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: calc(var(--z-toast) + 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: #2a2a2a;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.pull-to-refresh-indicator.ready {
    background: #4a7ba7;
}

.pull-to-refresh-indicator.refreshing .pull-spinner {
    animation: spin 1s linear infinite;
}

.pull-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    transition: transform 0.2s ease-out;
}

.pull-text {
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

/* Prevent overscroll on mobile during pull */
body.pull-to-refresh-active {
    overscroll-behavior-y: contain;
}

/* ========== DRAG-TO-REORDER TOUCH STYLES (WS2, S4-6) ========== */

/* Swipe indicators - hidden by default, shown during swipe gestures */
.swipe-indicator {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease-out;
    pointer-events: none;
    z-index: 1;
}

/* Swiping states for better visual feedback */
.todo-card.swiping {
    user-select: none;
}

.todo-card.swiping .todo-card-content {
    transition: none; /* Disable transition during swipe for smooth tracking */
}

.todo-card.swiping-left {
    /* Additional styling when swiping left can go here */
}

.todo-card.swiping-right {
    /* Additional styling when swiping right can go here */
}

.swipe-delete {
    left: 0;
    background: linear-gradient(90deg, #d32f2f 0%, #f44336 40%, rgba(244, 67, 54, 0.3) 80%, transparent 100%);
}

.swipe-edit {
    right: 0;
    background: linear-gradient(270deg, #1976d2 0%, #4a7ba7 40%, rgba(74, 123, 167, 0.3) 80%, transparent 100%);
}

.swipe-icon {
    font-size: 36px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
    line-height: 1;
}

.swipe-text {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    text-transform: uppercase;
}

/* Dragging states */
.todo-card.dragging {
    opacity: 0.5;
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-card) + 10);
    transition: none;
}

.category.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-card) + 10);
    transition: none;
}

/* Drag placeholder */
.drag-placeholder {
    border: 2px dashed #4a7ba7;
    background: rgba(74, 123, 167, 0.1);
    border-radius: 8px;
    height: var(--placeholder-height, 80px);
    margin-bottom: var(--spacing-card-gap);
}

/* Long press visual feedback */
.long-press-active {
    animation: longPressIndicate 0.5s ease-out;
}

@keyframes longPressIndicate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1.02);
    }
}

/* Touch drag handle (shown during long press) */
.drag-handle-indicator {
    position: absolute;
    top: 50%;
    left: -8px;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: #4a7ba7;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.long-press-active .drag-handle-indicator {
    opacity: 1;
}

/* Permanent drag handle (visible on all todo items) */
.todo-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-right: 8px;
    color: #6B7280; /* Neutral gray */
    cursor: grab;
    flex-shrink: 0;
    transition: color 0.2s ease, transform 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.todo-drag-handle svg {
    display: block;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* Hover state (desktop) */
.todo-drag-handle:hover {
    color: #374151; /* Darker gray */
}

/* Active/dragging state */
.todo-drag-handle:active,
.todo-card.dragging .todo-drag-handle {
    cursor: grabbing;
}

/* Mobile-specific: larger touch target */
@media (max-width: 768px) {
    .todo-drag-handle {
        padding: 8px;
        margin-right: 4px;
    }

    .todo-drag-handle svg {
        width: 20px;
        height: 20px;
    }

    .cat-filter-pill {
        padding: 5px 12px;
        font-size: var(--font-size-small);
        min-height: 28px;
    }

    .quick-add-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* ========== OVERFLOW MENU STYLES ========== */

/* Overflow menu button */
.overflow-menu-btn {
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
}

/* Desktop dropdown menu */
.overflow-menu-desktop {
    position: fixed;
    background-color: #363636;
    border: 1px solid #505050;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: var(--z-menu);
    min-width: 200px;
    padding: 8px 0;
    animation: fadeIn var(--transition-fast) var(--easing-enter);
}

/* Mobile bottom sheet */
.overflow-menu-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    display: flex;
    align-items: flex-end;
}

.overflow-menu-mobile[hidden] {
    display: none;
}

.overflow-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-backdrop);
    animation: fadeIn var(--transition-medium) var(--easing-enter);
}

.overflow-menu-sheet {
    position: relative;
    width: 100%;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    z-index: var(--z-drawer);
    transform: translateY(100%);
    transition: transform var(--transition-medium) var(--easing-enter);
    max-height: 60vh;
    overflow-y: auto;
}

.overflow-menu-sheet-open {
    transform: translateY(0) !important;
}

/* Swipe handle */
.overflow-menu-handle {
    width: 40px;
    height: 4px;
    background: #666;
    border-radius: 2px;
    margin: 12px auto;
    cursor: grab;
}

.overflow-menu-handle:active {
    cursor: grabbing;
}

/* Menu items */
.overflow-menu-items {
    padding: 0 16px 32px;
}

.overflow-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: var(--touch-target-large);
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.overflow-menu-item:hover,
.overflow-menu-item:active {
    background: #2a2a2a;
}

.overflow-menu-item:focus-visible {
    outline: 2px solid #4a7ba7;
    outline-offset: 2px;
}

.overflow-menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.overflow-menu-label {
    flex: 1;
    font-weight: 400;
}

/* Desktop menu items - more compact */
@media (min-width: 600px) {
    .overflow-menu-item {
        min-height: auto;
        padding: 10px 12px;
        gap: 12px;
    }

    .overflow-menu-icon {
        font-size: 18px;
        width: 20px;
    }

    .overflow-menu-label {
        font-size: 14px;
    }

    .overflow-menu-desktop {
        padding: 4px 0;
    }
}

/* Overflow menu user indicator & divider */
.overflow-menu-user {
    padding: 10px 16px;
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
    user-select: none;
}

.overflow-menu-divider {
    height: 1px;
    background: rgba(128, 128, 128, 0.2);
    margin: 4px 0;
}

.overflow-menu-item.danger {
    color: #e74c3c;
}

.overflow-menu-item.danger:hover,
.overflow-menu-item.danger:active {
    background: rgba(231, 76, 60, 0.1);
}

/* ========== VISUAL FEEDBACK POLISH (WS4, S5-4) ========== */

/* Performance optimizations - use GPU acceleration */
.todo-card,
.action-menu-drawer,
.toast,
.pull-to-refresh-indicator {
    will-change: transform;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Smooth transitions */
.todo-card[data-expanded="true"] {
    will-change: height, transform;
}

.swipe-indicator {
    will-change: transform, opacity;
}

/* Loading skeleton for async operations */
.skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 0%,
        #3a3a3a 50%,
        #2a2a2a 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton variations */
.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 80px;
    margin-bottom: var(--spacing-card-gap);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Keep essential animations but make them instant */
    .todo-card,
    .action-menu-drawer,
    .toast {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus-visible polyfill for better keyboard navigation */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

/* Enhanced touch feedback */
@media (hover: none) and (pointer: coarse) {
    /* Mobile-specific optimizations */

    /* Faster tap feedback on touch devices */
    button,
    .menu-icon,
    .todo-checkbox {
        -webkit-tap-highlight-color: rgba(74, 123, 167, 0.2);
        tap-highlight-color: rgba(74, 123, 167, 0.2);
    }

    /* Prevent text selection during interactions */
    .todo-card,
    .category-header {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    /* Improve scrolling physics */
    .todo-list,
    .categories-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* ========== FLOATING ACTION BUTTON (FAB) ========== */

.fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 150; /* Above cards, below modals */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7ba7 0%, #5a8bc7 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(74, 123, 167, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    color: white;
    position: relative;
    overflow: hidden;
}

.fab-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(74, 123, 167, 0.5);
}

.fab-button:active {
    transform: scale(0.95);
}

.fab-button.fab-open .fab-icon {
    transform: rotate(45deg);
}

.fab-icon {
    font-size: 28px;
    font-weight: 300;
    transition: transform var(--transition-medium);
    line-height: 1;
}

/* Speed Dial Menu */
.fab-speed-dial {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
}

.fab-speed-dial[hidden] {
    display: none;
}

.fab-speed-dial-action {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #363636;
    border: 1px solid #404040;
    border-radius: 28px;
    padding: 12px 16px 12px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fabSlideIn var(--transition-medium) var(--easing-enter);
    min-height: var(--touch-target-medium);
    white-space: nowrap;
}

.fab-speed-dial-action:hover {
    background: #404040;
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.fab-speed-dial-action:active {
    transform: translateX(-4px) scale(0.98);
}

.fab-speed-dial-icon {
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4a7ba7;
    border-radius: 50%;
    flex-shrink: 0;
}

.fab-speed-dial-label {
    color: #e0e0e0;
    font-size: 16px;
    font-weight: 500;
    padding-right: 4px;
}

/* Animation for speed dial items */
@keyframes fabSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Add staggered animation delay for multiple items */
.fab-speed-dial-action:nth-child(1) {
    animation-delay: 0ms;
}

.fab-speed-dial-action:nth-child(2) {
    animation-delay: 50ms;
}

/* Mobile responsive sizing */
@media (max-width: 600px) {
    .fab-container {
        bottom: 16px;
        right: 16px;
    }

    .fab-button {
        width: 56px; /* Keep 56px for better visibility */
        height: 56px;
    }

    .fab-speed-dial-action {
        min-height: var(--touch-target-medium);
    }
}

/* Backdrop for speed dial */
.fab-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 140; /* Below FAB container */
    animation: fadeIn var(--transition-fast);
}

.fab-backdrop[hidden] {
    display: none;
}

/* ========== LOADING STATES (Task 1 - P0) ========== */

/* Global loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-toast);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #404040;
    border-top-color: #4a7ba7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Inline loading indicator */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: #888;
    font-size: var(--font-size-small);
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Category loading state */
.category.loading {
    opacity: 0.6;
    pointer-events: none;
}

.category.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin-top: -12px;
    margin-left: -12px;
    border: 2px solid #404040;
    border-top-color: #4a7ba7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Todo card loading state */
.todo-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading bar at top of page */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #4a7ba7, #6fa7d4, #4a7ba7);
    background-size: 200% 100%;
    animation: loadingBar 1.5s ease-in-out infinite;
    z-index: var(--z-toast);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.loading-bar.visible {
    opacity: 1;
}

@keyframes loadingBar {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton loading for cards */
.skeleton {
    background: linear-gradient(90deg, #363636 25%, #404040 50%, #363636 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Disabled state during loading */
.disabled-during-loading {
    pointer-events: none;
    opacity: 0.5;
}

/* ========== ERROR BOUNDARY STYLES (Task 4 - P1) ========== */

.error-boundary-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    text-align: center;
    background-color: #2d2d2d;
    border: 1px solid #ff6b6b;
    border-radius: 8px;
    margin: var(--spacing-md);
}

.error-boundary-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.error-boundary-message {
    color: #e0e0e0;
    font-size: var(--font-size-body);
    margin: 0 0 var(--spacing-md) 0;
}

.error-boundary-retry {
    background-color: #4a7ba7;
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-size-body);
    min-height: var(--touch-target-medium);
    transition: background-color var(--transition-fast);
}

.error-boundary-retry:hover,
.error-boundary-retry:focus {
    background-color: #5a8bb7;
}

.error-boundary-retry:focus-visible {
    outline: 2px solid #6fa7d4;
    outline-offset: 2px;
}

/* Loading state within containers */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    text-align: center;
}

.loading-state p {
    color: #888;
    margin-top: var(--spacing-md);
}

/* ========== BASE DRAWER COMPONENT (Task 9 - P2) ========== */

.base-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    display: flex;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-medium), visibility var(--transition-medium);
}

.base-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.base-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-backdrop);
}

.base-drawer-container {
    position: relative;
    width: 100%;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    z-index: var(--z-drawer);
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform var(--transition-medium) var(--easing-enter);
}

.base-drawer-overlay.active .base-drawer-container {
    transform: translateY(0);
}

.base-drawer-handle {
    width: 40px;
    height: 4px;
    background: #666;
    border-radius: 2px;
    margin: 12px auto;
    cursor: grab;
}

.base-drawer-handle:active {
    cursor: grabbing;
}

.base-drawer-content {
    padding: 0 var(--spacing-md) var(--spacing-xl);
}

/* ========== AUTH OVERLAY ========== */

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1a1a1a;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.auth-overlay[hidden] {
    display: none;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-lg);
}

.auth-title {
    text-align: center;
    color: #e0e0e0;
    font-size: 36px;
    margin-bottom: var(--spacing-xl);
}

.auth-form h2 {
    color: #e0e0e0;
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    font-size: 20px;
}

.auth-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: var(--spacing-sm);
}

.auth-error {
    color: #f44336;
    font-size: 14px;
    margin-bottom: var(--spacing-sm);
    padding: 8px 12px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 4px;
}

.auth-switch {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-top: var(--spacing-md);
}

.auth-switch a {
    color: #4a7ba7;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ========== DESKTOP OPTIMIZATIONS ========== */
/* Tighter spacing and smaller hit targets for mouse/trackpad users on larger screens */
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    :root {
        --touch-target-large: 36px;
        --touch-target-medium: 32px;
        --touch-target-small: 28px;
        --spacing-card: 10px;
        --spacing-card-gap: 6px;
        --font-size-body: 14px;
        --font-size-header: 16px;
        --font-size-small: 13px;
        --font-size-icon: 18px;
        --font-size-icon-sm: 16px;
        --font-size-icon-md: 14px;
    }

    body {
        padding: var(--spacing-sm);
    }

    #app {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    /* Header */
    .app-header {
        margin-bottom: var(--spacing-sm);
    }

    .icon-btn {
        min-width: var(--touch-target-large);
        min-height: var(--touch-target-large);
        padding: 6px;
        border-radius: var(--radius-md);
        font-size: var(--font-size-icon);
    }

    /* Tabs */
    .tab-container {
        margin-bottom: var(--spacing-md);
    }

    .tab {
        padding: 6px var(--spacing-sm);
        font-size: var(--font-size-small);
    }

    .tab-scroll-btn {
        min-width: var(--touch-target-medium);
        min-height: var(--touch-target-medium);
        padding: 6px;
    }

    /* Filter pills */
    .filter-section {
        margin-bottom: var(--spacing-sm);
    }

    .filter-pill {
        min-height: var(--touch-target-medium);
        padding: 4px 10px;
        font-size: var(--font-size-small);
    }

    /* Categories container */
    #categoriesContainer {
        gap: var(--spacing-sm);
        padding-top: var(--spacing-sm);
    }

    /* Category cards */
    .category {
        min-width: 300px;
        max-width: 700px;
    }

    .category-header {
        padding: 6px var(--spacing-sm);
        min-height: var(--touch-target-medium);
    }

    .category-header span {
        font-size: var(--font-size-body);
    }

    .category-menu {
        min-width: var(--touch-target-medium);
        min-height: var(--touch-target-medium);
        padding: 4px;
    }

    .category-filters {
        padding: 3px var(--spacing-sm);
    }

    .cat-filter-pill {
        padding: 2px 8px;
        font-size: 11px;
    }

    /* Todos container */
    .todos-container {
        padding: var(--spacing-xs);
        min-height: var(--touch-target-small);
    }

    /* Todo cards */
    .todo-card-header {
        padding: var(--spacing-card);
        gap: var(--spacing-card-gap);
    }

    .todo-checkbox {
        min-width: var(--touch-target-medium);
        min-height: var(--touch-target-medium);
    }

    .todo-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .todo-text {
        font-size: var(--font-size-body);
        line-height: 1.4;
    }

    .todo-text-container {
        max-width: calc(100% - 90px);
    }

    .menu-icon {
        min-width: var(--touch-target-medium);
        min-height: var(--touch-target-medium);
        font-size: var(--font-size-icon-sm);
    }

    .todo-drag-handle {
        padding: 2px;
        margin-right: 4px;
    }

    .todo-drag-handle svg {
        width: 16px;
        height: 16px;
    }

    /* Priority badge */
    .priority-badge {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* Metadata */
    .todo-metadata {
        padding: var(--spacing-xs) var(--spacing-sm);
        gap: var(--spacing-xs);
        margin-bottom: var(--spacing-xs);
    }

    .todo-text-full {
        padding: var(--spacing-sm);
        padding-top: 0;
        font-size: var(--font-size-body);
    }

    /* Quick add */
    .quick-add-wrapper {
        padding: var(--spacing-xs) 0;
        margin-top: var(--spacing-xs);
    }

    .quick-add-input {
        padding: 6px var(--spacing-sm);
        font-size: var(--font-size-small);
    }

    /* FAB */
    .fab-button {
        width: 48px;
        height: 48px;
    }

    .fab-button .fab-icon {
        font-size: 22px;
    }

    .fab-speed-dial-action {
        min-height: var(--touch-target-medium);
        padding: 8px 14px;
        font-size: var(--font-size-small);
    }

    /* Modals */
    .modal-content {
        padding: var(--spacing-md);
    }

    .modal-field {
        margin-bottom: var(--spacing-sm);
    }

    .modal-field input,
    .modal-field select,
    .modal-field textarea {
        padding: 6px 8px;
        font-size: var(--font-size-body);
    }

    .modal-button {
        min-height: var(--touch-target-medium);
        padding: 6px 16px;
        font-size: var(--font-size-small);
    }

    /* Search */
    .search-input-wrapper {
        height: var(--touch-target-large);
    }

    .search-input {
        font-size: var(--font-size-body);
    }

    /* Collapsed categories */
    .collapsed-categories-container {
        gap: var(--spacing-xs);
    }

    .category.collapsed-category .category-header {
        padding: 4px var(--spacing-sm);
    }
}

/* =========================================================
   Subtasks — Phase 1
   ========================================================= */

/* Progress bar on collapsed parent card */
.subtask-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.subtask-count {
    font-size: var(--font-size-badge);
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 28px;
    flex-shrink: 0;
}

.subtask-bar {
    flex: 1;
    height: 3px;
    background: var(--color-border-default);
    border-radius: 2px;
    overflow: hidden;
    max-width: 80px;
}

.subtask-bar-fill {
    height: 100%;
    background: var(--color-accent-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Next action hint (Phase 4) */
.next-action {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.todo-card[data-expanded="true"] .next-action {
    display: none;
}

/* Status timestamp (Phase 3) */
.todo-status-time {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Inline subtask list inside expanded parent */
.subtask-section {
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--color-border-default);
}

.subtask-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 4px var(--spacing-xs);
    border-radius: var(--radius-sm);
    cursor: default;
    transition: background 0.1s;
}

.subtask-item:hover {
    background: var(--color-bg-card-hover);
}

.subtask-item.completed .subtask-text {
    text-decoration: line-through;
    color: var(--color-text-muted);
    opacity: 0.65;
}

.subtask-item.subtask-dragging {
    opacity: 0.4;
}

.subtask-item.subtask-drag-over {
    border-top: 2px solid var(--color-accent-primary);
}

.subtask-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--color-accent-primary);
}

.subtask-text {
    flex: 1;
    font-size: var(--font-size-small);
    color: var(--color-text-secondary);
    line-height: 1.4;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subtask-delete-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.subtask-item:hover .subtask-delete-btn {
    opacity: 1;
}

.subtask-delete-btn:hover {
    color: var(--color-error);
    background: rgba(255, 77, 77, 0.1);
}

.subtask-add-wrapper {
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
}

.subtask-add-input {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--color-border-light);
    padding: 4px 2px;
    font-size: var(--font-size-small);
    color: var(--color-text-secondary);
    outline: none;
    transition: border-color 0.15s;
}

.subtask-add-input:focus {
    border-bottom-color: var(--color-accent-primary);
}

.subtask-add-input::placeholder {
    color: var(--color-text-muted);
}

/* Disabled checkbox for parent todos */
.todo-checkbox input[type="checkbox"]:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* =========================================================
   Status States — Phase 2
   ========================================================= */

/* In Progress: blue left border + subtle tint */
.todo-card[data-status="in-progress"]:not(.completed) {
    border-left: 3px solid var(--color-accent-primary);
    padding-left: calc(var(--spacing-md) - 3px);
    background: rgba(74, 123, 167, 0.05);
}

/* Blocked: amber left border + subtle tint */
.todo-card[data-status="blocked"]:not(.completed) {
    border-left: 3px solid var(--color-warning);
    padding-left: calc(var(--spacing-md) - 3px);
    background: rgba(255, 152, 0, 0.05);
}

/* Blocked icon inline with title */
.blocked-icon {
    font-size: 12px;
    margin-left: 3px;
    color: var(--color-warning);
}

/* =========================================================
   Status filter pills — Phase 2
   ========================================================= */

.filter-pill-in-progress {
    border-color: var(--color-accent-primary) !important;
}

.filter-pill-in-progress.active {
    background: var(--color-accent-primary) !important;
    color: white !important;
}

.filter-pill-blocked {
    border-color: var(--color-warning) !important;
}

.filter-pill-blocked.active {
    background: var(--color-warning) !important;
    color: white !important;
}

.filter-pill-stale {
    border-color: var(--color-error) !important;
}

.filter-pill-stale.active {
    background: var(--color-error) !important;
    color: white !important;
}

/* =========================================================
   Action menu status items
   ========================================================= */

.action-menu-item-active {
    font-weight: 600;
}

.action-menu-item-active .action-menu-icon {
    color: var(--color-accent-primary);
}

.action-menu-check {
    margin-left: auto;
    color: var(--color-accent-primary);
    font-size: 14px;
}
