:root {
    /* Cheerful Palette */
    --bg-color: #ffffff; /* Main area white background */
    --sidebar-bg: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent-primary: #0066ff; /* Bright Flat Blue */
    --accent-success: #00c853; /* Bright Flat Green */
    --accent-warning: #ffd600; /* Bright Flat Yellow */
    --accent-danger: #ff1744;  /* Bright Flat Red */
    --accent-purple: #d500f9;  /* Bright Flat Purple */
    
    /* UI Elements */
    --card-bg: #ffffff;
    --border-radius: 8px;
    --shadow: none; /* No drop shadows */
    --sidebar-width: 260px;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

aside {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}

body.sidebar-hidden aside {
    width: 0;
    padding: 0;
    opacity: 0;
    border-right: none;
    pointer-events: none;
    transform: translateX(-20px);
}

body.focus-mode aside {
    width: 0;
    padding: 0;
    opacity: 0;
    border-right: none;
    pointer-events: none;
}

body.focus-mode header,
body.focus-mode .view-header {
    display: none !important;
}

body.focus-mode #view-container {
    padding: 10px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-primary);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-group {
    margin-bottom: 25px;
}

.nav-group h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 10px;
}

.nav-item {
    padding: 12px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.nav-item:hover {
    background-color: #f7fafc;
    color: var(--accent-primary);
}

.nav-item.active {
    background-color: #ebf4ff;
    color: var(--accent-primary);
    font-weight: 600;
}

main {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
    min-height: 0;
    flex: 1; /* Ensure main fills available vertical space */
}

header {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 120px; /* leave room for focus toggle + show-hidden-columns fixed buttons */
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.breadcrumb-item {
    cursor: pointer;
    transition: color 0.2s ease;
}

.breadcrumb-item:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.sidebar-toggle-btn {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    margin-right: 15px;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    font-size: 0.8rem;
    position: relative;
}

.sidebar-toggle-btn:hover {
    background: #ffffff;
    color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.sidebar-toggle-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
}

.sidebar-toggle-btn.active:hover {
    background: #0052cc;
}

/* Focus mode toggle is fixed to top-right so it stays visible in focus mode */
.focus-mode-toggle-btn {
    position: fixed;
    top: 19px;
    right: 30px;
    z-index: 1001;
    margin-right: 0;
}

/* Show All Columns button — sits to the left of the focus toggle */
.show-all-columns-btn {
    position: fixed;
    top: 19px;
    right: 76px;
    z-index: 1001;
    margin-right: 0;
    display: none;
}

/* Icon rotation - we rotate the span instead of the button 
   so the tooltip doesn't rotate with it */
.sidebar-toggle-btn .icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

body.sidebar-hidden .sidebar-toggle-btn .icon {
    transform: rotate(180deg);
}

/* Custom Tooltip */
.sidebar-toggle-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: var(--text-main);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 100;
}

.sidebar-toggle-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
}

#global-search {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background-color: #f7fafc;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

#global-search:focus {
    border-color: var(--accent-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(77, 150, 255, 0.1);
}

.view-controls {
    display: flex;
    background: #edf2f7;
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.view-btn:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.view-btn.active {
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-weight: 600;
    animation: activePulse 2s infinite ease-in-out;
}

.scratchpad-header-btn {
    margin-left: 12px;
    background: #edf2f7;
    border-radius: 8px;
    padding: 6px 16px;
}

.scratchpad-header-btn.active {
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 600;
}

#view-container {
    flex: 1;
    padding: 30px 30px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.recenter-utility-btn {
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    color: var(--text-main);
    padding: 6px 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recenter-utility-btn:hover {
    background: #f7fafc;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}


/* Kanban Board Layout */
.kanban-board {
    display: flex;
    gap: 20px;
    padding-bottom: 20px;
    overflow-x: auto;
    flex: 1;
    min-height: 0;
    flex-wrap: nowrap; /* Ensure columns do not wrap */
    align-items: stretch; /* Columns fill full board height */
}

.kanban-add-column-btn {
    transition: all 0.2s ease;
}
.kanban-add-column-btn:hover {
    border-color: var(--accent-primary) !important;
    transform: scale(1.05);
}
.kanban-add-column-btn.drag-over {
    background: #e1effe !important; /* Nesting indicator */
    box-shadow: 0 0 0 2px var(--accent-primary);
    border-color: var(--accent-primary) !important;
}
.kanban-column {
    border-radius: var(--border-radius);
    width: 320px;
    min-width: 320px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

.kanban-column.drag-over {
    background: #e8f0fe;
    outline: 2px dashed var(--accent-primary);
    outline-offset: -2px;
}

.kanban-column.column-dragging {
    opacity: 0.4;
    border: 2px dashed var(--accent-primary);
}

.column-header {
    padding: 13px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}



.kanban-cards {
    padding: 8px 10px 10px 10px;
    overflow-y: auto;
    flex: 1;
}

/* Kanban Cards */
.kanban-card {
    background: var(--card-bg);
    padding: 10px 16px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid var(--accent-primary);
    user-select: none;
    position: relative;
}

.kanban-card.dragging {
    opacity: 0.5;
    border-style: dashed;
}

.kanban-card.drag-over {
    background: #e1effe; /* Nesting indicator */
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.kanban-card.drag-before {
    border-top: 4px solid var(--accent-primary);
    margin-top: -4px;
}

.kanban-card.drag-after {
    border-bottom: 4px solid var(--accent-primary);
    margin-bottom: -4px;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.kanban-card.selected {
    border-color: var(--accent-primary);
    background-color: #ebf4ff;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.card-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95rem;
    text-align: center;
    padding: 0 16px;
}

.edit-card-btn {
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: all 0.2s ease;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}

.kanban-card:hover .edit-card-btn {
    opacity: 1;
    pointer-events: auto;
}

.edit-card-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.edit-card-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
}

/* ─── Scratchpad card button ─────────────────────────────────────────────── */
.scratchpad-card-btn {
    position: absolute;
    bottom: 10px;
    right: 40px;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: background 0.15s, color 0.15s;
}
.kanban-card:hover .scratchpad-card-btn {
    opacity: 1;
    pointer-events: auto;
}
.scratchpad-card-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ─── Scratchpad view ────────────────────────────────────────────────────── */
.scratchpad-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    background: #f0f9ff;
    border-bottom: 1px solid #bae6fd;
    font-size: 0.82rem;
    flex-shrink: 0;
}
.scratchpad-banner-label {
    color: #0284c7;
    font-weight: 600;
}
.scratchpad-banner-target {
    color: var(--text-main, #0f172a);
    font-weight: 500;
}
.scratchpad-banner-new {
    color: var(--text-muted, #64748b);
}
.scratchpad-banner-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #0284c7;
    font-size: 0.8rem;
    padding: 0 2px;
    opacity: 0.7;
    margin-left: 2px;
}
.scratchpad-banner-clear:hover { opacity: 1; }

.scratchpad-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: var(--bg-card, #fff);
}
.scratchpad-tool-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted, #64748b);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.scratchpad-tool-btn:hover,
.scratchpad-tool-btn.active {
    background: var(--accent-primary, #0066ff);
    color: #fff;
    border-color: var(--accent-primary, #0066ff);
}

.scratchpad-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.scratchpad-textarea {
    flex: 1;
    resize: none;
    padding: 16px 20px;
    border: none;
    border-right: 1px solid #e2e8f0;
    outline: none;
    font-size: 0.88rem;
    font-family: ui-monospace, 'Cascadia Code', 'Fira Mono', monospace;
    line-height: 1.65;
    background: var(--bg-main, #f8fafc);
    color: var(--text-main, #0f172a);
    min-width: 0;
}
.scratchpad-textarea:focus {
    background: #fff;
}

.scratchpad-preview {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-card, #fff);
    transition: width 0.2s ease;
}
.scratchpad-preview.hidden {
    width: 0;
    overflow: hidden;
}
.scratchpad-preview-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 12px 18px 8px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.scratchpad-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px 16px;
}

.scratchpad-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: var(--bg-card, #fff);
}
.scratchpad-count {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
}
.scratchpad-export-btn {
    padding: 8px 22px;
    background: var(--accent-primary, #0066ff);
    color: #fff;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.15s;
}
.scratchpad-export-btn:hover:not(:disabled) {
    opacity: 0.88;
}

/* Floating Action Button */
.add-node-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.add-node-btn:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 6px 20px rgba(77, 150, 255, 0.6);
}

.add-node-btn:active {
    transform: scale(0.95) translateY(0);
}

/* Smart View panels (Next Actions, Coming Due, Tags, Search) */
.todo-list {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    min-height: 200px;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #edf2f7;
    cursor: pointer;
    border-left: 4px solid var(--accent-primary);
    margin-bottom: 4px;
    border-radius: 4px;
    background: white;
}

.todo-item:hover {
    background: #f7fafc;
    transform: translateX(4px);
}

.todo-main {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.todo-title {
    font-weight: 500;
    flex: 1;
}

.category-chip {
    font-size: 0.75rem;
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}

.tag-chip {
    font-size: 0.75rem;
    background: #ebf4ff;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent-primary);
    border: 1px solid #d1e9ff;
}

/* Card front / back faces (Phase 2 & 3) */
.card-front { display: block; }
.card-back  { display: none; padding-bottom: 28px; }

.kanban-card.card-flipped .card-front { display: none; }
.kanban-card.card-flipped .card-back  { display: block; }

/* Hide action buttons while viewing the back */
.kanban-card.card-flipped .scratchpad-card-btn,
.kanban-card.card-flipped .edit-card-btn { display: none; }

/* Flip button — sits with scratchpad/edit buttons, bottom-right */
.card-flip-btn {
    position: absolute;
    bottom: 10px;
    right: 70px;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: background 0.15s, color 0.15s;
}

.kanban-card:hover .card-flip-btn         { opacity: 1; pointer-events: auto; }
.card-flip-btn:hover                       { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }
/* Always visible when on back so user can return */
.kanban-card.card-flipped .card-flip-btn  { opacity: 1; pointer-events: auto; }

/* Detail icons — bottom-left, reserved for future use */
.card-detail-icons {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 4px;
    align-items: center;
    color: var(--text-main);
    font-size: 0.8rem;
}

/* Card front fields (Phase 2 metadata display) */
.card-front-fields {
    margin: 8px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.card-front-field {
    display: flex;
    gap: 5px;
    font-size: 0.75rem;
    line-height: 1.35;
    align-items: center;
    flex-wrap: wrap;
}

/* Lucide icon inside a card field value */
.card-field-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    flex-shrink: 0;
}
.card-field-icon svg {
    width: 13px;
    height: 13px;
}

.card-front-field-label {
    font-weight: 700;
    opacity: 0.7;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-front-field-value {
    word-break: break-word;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
    background: #fcfcfc;
    border: 2px dashed #edf2f7;
    border-radius: 8px;
}

/* ── Perspective results ──────────────────────────────────────────────────── */

.perspective-group {
    margin-bottom: 28px;
}

.perspective-group-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 4px 8px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 8px;
}

/* Status-based left border on result rows */
.perspective-result.perspective-status-active    { border-left-color: var(--accent-primary); }
.perspective-result.perspective-status-completed { border-left-color: #22c55e; opacity: 0.7; }
.perspective-result.perspective-status-abandoned { border-left-color: #94a3b8; opacity: 0.55; }

.perspective-path {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Priority badge — single letter, coloured pill */
.perspective-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 800;
    flex-shrink: 0;
    color: #fff;
}
.perspective-priority-high   { background: #ef4444; }
.perspective-priority-medium { background: #f59e0b; }
.perspective-priority-low    { background: #94a3b8; }

/* Deadline chip */
.perspective-deadline {
    font-size: 0.72rem;
    color: #f59e0b;
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
}

/* ── Project tree view (groupBy: 'project') ─────────────────────────────── */

.perspective-project-group {
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.perspective-project-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary, #f8f9fa);
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.1s;
}

.perspective-project-header:hover {
    background: #edf2f7;
}

.perspective-project-count {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #e2e8f0;
    border-radius: 10px;
    padding: 1px 8px;
    white-space: nowrap;
}

.perspective-tree-toggle {
    font-size: 0.78rem;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.perspective-project-body {
    padding: 14px 16px;
}

.perspective-project-body.is-collapsed {
    display: none;
}

/* Intermediate tree branch */
.perspective-tree-branch {
    margin-bottom: 10px;
}

.perspective-tree-branch-header {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-secondary, #4a5568);
    user-select: none;
    transition: background 0.1s;
}

.perspective-tree-branch-header:hover {
    background: #f0f4f8;
}

.perspective-tree-children {
    padding-left: 14px;
    border-left: 2px solid #e2e8f0;
    margin-left: 17px;
    margin-top: 6px;
}

.perspective-tree-children.is-collapsed {
    display: none;
}

/* Card grid for result nodes */
.perspective-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    padding: 8px 0;
}

.perspective-card {
    background: var(--bg-primary, #fff);
    border: 1px solid #e2e8f0;
    border-left-width: 3px;
    border-radius: 8px;
    padding: 11px 13px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
}

.perspective-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-primary, #667eea);
}

.perspective-card.perspective-status-active    { border-left-color: var(--accent-primary, #667eea); }
.perspective-card.perspective-status-completed { border-left-color: #22c55e; opacity: 0.65; }
.perspective-card.perspective-status-abandoned { border-left-color: #94a3b8; opacity: 0.5; }

.perspective-card-title {
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1.35;
    word-break: break-word;
}

/* ── Kanban filter bar ────────────────────────────────────────────────────── */

/* ── Kanban board wrap (board only, excludes filter bar) ─────────────── */
.kanban-board-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Filter bar ──────────────────────────────────────────────────────── */
.kanban-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-secondary, #f8f9fa);
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ── Dropdown trigger buttons ────────────────────────────────────────── */
.filter-dropdown {
    position: relative;
    flex-shrink: 0;
}

.filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: var(--bg-primary, #fff);
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary, #4a5568);
    transition: border-color 0.1s, color 0.1s, background 0.1s;
    white-space: nowrap;
    line-height: 1.5;
    font-family: inherit;
}

.filter-trigger:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.filter-trigger.filter-active {
    background: #eff6ff;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: #fff;
    border-radius: 10px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    line-height: 16px;
}

.filter-caret {
    font-size: 0.6rem;
    opacity: 0.5;
    margin-left: 1px;
}

/* ── Dropdown panels ─────────────────────────────────────────────────── */
.filter-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 300;
    background: var(--bg-primary, #fff);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 160px;
    padding: 5px 0;
}

.filter-panel.open {
    display: block;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-main);
    transition: background 0.1s;
    user-select: none;
}

.filter-option:hover {
    background: var(--bg-secondary, #f8f9fa);
}

.filter-option input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

.filter-panel-empty {
    padding: 8px 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Date range panel ────────────────────────────────────────────────── */
.filter-panel-date {
    min-width: 230px;
    padding: 10px 14px;
    display: none;
    flex-direction: column;
    gap: 6px;
}

.filter-panel-date.open {
    display: flex;
}

.filter-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-date-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 34px;
    flex-shrink: 0;
}

.filter-date-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-primary, #fff);
}

.filter-date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filter-date-clear {
    margin-top: 4px;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: none;
    font-size: 0.76rem;
    cursor: pointer;
    color: var(--text-muted);
    font-family: inherit;
    width: 100%;
    text-align: center;
    transition: border-color 0.1s, color 0.1s;
}

.filter-date-clear:hover {
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

/* ── Meta zone: count + clear-all ───────────────────────────────────── */
.filter-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
}

.filter-toggle {
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: var(--bg-primary, #fff);
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary, #4a5568);
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.filter-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.filter-clear {
    border-color: #fed7d7;
    color: var(--accent-danger);
    background: #fff5f5;
}

.filter-clear:hover {
    background: var(--accent-danger);
    color: #fff;
    border-color: var(--accent-danger);
}

/* ── Snapshot button ─────────────────────────────────────────────────── */
.filter-snapshot-btn {
    margin-left: auto;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: var(--bg-primary, #fff);
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    white-space: nowrap;
    font-family: inherit;
}

.filter-snapshot-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: #f0f4ff;
}

/* Editor Full-Screen Modal */
.editor-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary, #fff);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.editor-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.editor-overlay {
    display: none;
}

.editor-header {
    padding: 16px 32px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.editor-header-info h2 {
    margin: 0 0 4px;
    font-size: 1.1rem;
}

.editor-header-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 14px;
}

.editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
    align-content: start;
}

.editor-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-col-custom .section-divider:first-child {
    margin-top: 0;
}

.editor-footer {
    padding: 14px 32px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.editor-footer-destructive {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-footer-sep {
    display: inline-block;
    width: 1px;
    height: 24px;
    background: var(--border-color, #e2e8f0);
    margin: 0 4px;
}

.editor-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modals (showTypeEditor, showTemplateEditor, etc.) */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

.modal-box {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    min-width: 360px;
    max-width: 90vw;
    max-height: 82vh;
    overflow-y: auto;
}

.modal-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Label row with inline F/B display toggles */
.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.field-display-toggles {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    margin-left: 8px;
}

.field-display-toggle {
    padding: 1px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1.5;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.field-display-toggle:hover:not(.active) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.field-display-toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

/* Section divider (used for Custom Fields heading) */
.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0 14px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color, #e2e8f0);
}

/* Custom field rows */
.custom-field-row {
    margin-bottom: 12px;
}

.custom-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.custom-field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.custom-field-value {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a202c);
    box-sizing: border-box;
}

.custom-field-value:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(77,150,255,0.1);
}

.field-delete-btn {
    padding: 1px 6px;
    font-size: 0.85rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 3px;
    line-height: 1.5;
    margin-left: 4px;
    transition: background 0.12s, color 0.12s;
}

.field-delete-btn:hover {
    background: #fed7d7;
    color: var(--accent-danger, #e53e3e);
    border-color: #fed7d7;
}

/* Add-field row at bottom of custom fields */
.add-field-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
    margin-bottom: 8px;
}

.add-field-label-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    min-width: 0;
}

.add-field-label-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(77,150,255,0.1);
}

.add-field-type-select {
    padding: 7px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    background: var(--bg-primary, #fff);
    flex-shrink: 0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    flex-shrink: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn-primary { background: var(--accent-primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-danger { background: #fff5f5; color: var(--accent-danger); border: 1px solid #fed7d7; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-secondary { background: #edf2f7; color: var(--text-main); border: 1px solid #e2e8f0; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Tree View Styles */
.tree-view-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    touch-action: none;
    background-color: var(--bg-color);
    user-select: none !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.tree-view-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 8000px;
    height: 6000px;
    transform-origin: 0 0;
}

/* .tree-branch and .tree-children-container are no longer used (Phase 3 rewrite)
   but kept here as empty rules in case any other CSS references them. */
.tree-branch { }

.tree-node-item {
    /* Absolute positioning — JS sets left/top from treeLayout or auto-layout */
    position: absolute;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    border: 2px solid #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    z-index: 2;
    user-select: none !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.tree-node-item .tree-node-title {
    flex: 1;
    text-align: center;
    padding-left: 8px; /* Adjust for icons */
}

.tree-node-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
    z-index: 3;
}

.tree-node-item.dragging {
    opacity: 0.5;
    border-style: dashed;
}

.tree-node-item.drag-over {
    background: #e1effe;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.tree-node-item.selected {
    border-color: var(--accent-primary);
    border-width: 2px;
    background-color: #ebf4ff;
}

.tree-node-item.search-match {
    background-color: var(--accent-warning);
    border-color: #f59f00;
    color: #452b00;
    border-width: 2px;
}

/* Legacy selectors — no longer generated by tree.js Phase 3 rewrite */
.tree-children-container { display: none; }
.tree-children-container::before { display: none; }
.tree-branch:not(:only-child) > .tree-node-item::after { display: none; }

/* Step 9: Final Polish & View Animations */
@keyframes viewEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#active-view-content, .view-header, .empty-state {
    animation: viewEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes activePulse {
    0% { outline: 2px solid transparent; }
    50% { outline: 3px solid rgba(0, 102, 255, 0.4); }
    100% { outline: 2px solid transparent; }
}

.nav-item, .view-btn, .kanban-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Tree nodes use position-based layout; only transition border/shadow, not geometry */
.tree-node-item {
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tree-node-item.dragging {
    transition: none;
}

.selection-box {
    position: absolute;
    border: 1px solid var(--accent-primary);
    background: rgba(77, 150, 255, 0.1);
    pointer-events: none;
    z-index: 1000;
    display: none;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    z-index: 2000;
    padding: 5px 0;
    min-width: 160px;
    animation: viewEnter 0.2s ease-out;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: visible; /* Ensure submenus can break out */
}

.context-menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background 0.2s, color 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background: #f7fafc;
    color: var(--accent-primary);
}

.context-menu-item.has-submenu::after {
    content: '›';
    margin-left: auto;
    font-weight: bold;
    font-size: 1.1rem;
}

.context-menu-submenu {
    position: absolute;
    left: 100%;
    top: -2px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    min-width: 140px;
    display: none;
    padding: 5px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 2001; /* Slightly higher than parent menu */
}

.context-menu-item:hover > .context-menu-submenu {
    display: block;
}

.menu-tick { width: 14px; color: var(--accent-success); font-weight: bold; }
.menu-tick-space { width: 14px; }

/* Reveal/conceal toggle — top-left of card front */
.card-reveal-btn {
    position: absolute;
    top: 6px;
    left: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 2.2rem;
    color: inherit;
    opacity: 0.25;
    padding: 2px;
    z-index: 5;
    line-height: 1;
    transition: opacity 0.15s;
}
.kanban-card:hover .card-reveal-btn { opacity: 0.75; }
.card-reveal-btn:hover { opacity: 1 !important; }

.card-notes {
    font-size: 0.8rem;
    opacity: 0.7;
    margin: 4px 0 8px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
}

/* Collapsed state: hide all card content except the title */
.kanban-card.card-front-collapsed .card-front .card-front-fields,
.kanban-card.card-front-collapsed .card-front .card-notes,
.kanban-card.card-front-collapsed .card-front .card-meta,
.kanban-card.card-front-collapsed .card-front .card-checklist { display: none; }

/* Card Checklist Styling */
.card-checklist {
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    cursor: default;
}

.checklist-drag-handle {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    cursor: grab;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: opacity 0.15s;
    user-select: none;
}

.checklist-item:hover .checklist-drag-handle {
    opacity: 0.5;
}

.checklist-item:hover .checklist-drag-handle:hover {
    opacity: 1;
}

.checklist-dragging {
    opacity: 0.35;
}

.checklist-drop-indicator {
    height: 2px;
    background: var(--accent-primary);
    border-radius: 2px;
    pointer-events: none;
    margin-top: 2px;
    margin-bottom: 2px;
}

.checklist-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin-top: 2px;
    cursor: pointer;
}

.checklist-title.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Non-leaf checklist items (sub-list headers) */
.checklist-item.checklist-header {
    margin-top: 0.5em;
}

.checklist-item.checklist-header .checklist-title {
    font-weight: 700;
}

.empty-checklist {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Settings list rows (Templates / Types) ──────────────────────────────── */

.settings-list-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.settings-list-row:last-child {
    border-bottom: none;
}

.settings-list-row-info {
    flex: 1;
    min-width: 0;
}

.settings-list-row-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-list-row-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.settings-list-row-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.checklist-add-btn {
    display: block;
    margin-top: 8px;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.checklist-add-btn:hover {
    opacity: 1;
}

.checklist-toggle:hover {
    text-decoration: underline;
}

/* Toast Notification */
.toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--text-main);
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px 20px;
    position: fixed;
    z-index: 10000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.toast-notification.show {
    visibility: visible;
    opacity: 1;
    animation: fadein 0.5s, fadeout 0.5s 1.5s;
}

@keyframes fadein {
    from {bottom: 0; opacity: 0;}
    to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
    from {bottom: 30px; opacity: 1;}
    to {bottom: 0; opacity: 0;}
}

/* ── Lucide icon sizing in nav / header ────────────────────────────────────── */
aside .nav-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.view-btn svg {
    width: 13px;
    height: 13px;
    vertical-align: middle;
}

/* ── Icon picker button (in editor fields + perspective editor) ─────────────── */
.icon-picker-btn {
    width: 44px;
    height: 44px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: var(--card-bg, #fff);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-muted, #64748b);
    transition: border-color 0.15s, background 0.15s;
    padding: 0;
}
.icon-picker-btn:hover {
    border-color: var(--accent-primary, #0066ff);
    background: var(--hover-bg, #f8fafc);
}
.icon-picker-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Icon picker modal grid ─────────────────────────────────────────────────── */
.icon-picker-item {
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-main, #0f172a);
    transition: border-color 0.1s, background 0.1s;
}
.icon-picker-item:hover {
    background: var(--hover-bg, #f8fafc);
    border-color: #e2e8f0;
}
.icon-picker-item.selected {
    background: #ebf4ff;
    border-color: var(--accent-primary, #0066ff);
}
.icon-picker-item svg {
    width: 17px;
    height: 17px;
    pointer-events: none;
}