/* ========================================
   PROJECTS PAGE - FROST COSMIC DESIGN SYSTEM
   Standalone CSS (no external dependencies)
   HyperKnowledge 3000 (hk3k)
   ======================================== */

/* --- 1. CSS Custom Properties --- */
:root {
    --deep-blue: #0D1B2A;
    --rich-blue: #1B2A41;
    --brand-blue: #2E4F7E;
    --vibrant-cyan: #00E5FF;
    --electric-cyan: #33EBFF;
    --glow-cyan: #66F0FF;
    --purple: #8B5CF6;
    --royal-blue: #3B82F6;
    --white: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;

    --border-radius: 0;

    --glass-fill: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-strong: rgba(255, 255, 255, 0.2);
    --cyan-glass-border: rgba(0, 229, 255, 0.15);
    --cyan-glass-border-strong: rgba(0, 229, 255, 0.3);

    --font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-small: 0.8125rem;
    --font-size-body: 0.9375rem;
    --font-size-heading: 1.125rem;

    --shadow-glow-cyan: 0 0 20px rgba(0, 229, 255, 0.3);
    --shadow-glow-cyan-strong: 0 0 30px rgba(0, 229, 255, 0.6);
    --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.6);

    --transition: all 0.15s ease;
    --transition-slow: all 0.3s ease;

    --z-header: 30;
    --z-sidebar: 20;
    --z-overlay: 40;
    --z-context-menu: 50;

    --header-height: 56px;
    --sidebar-width: 360px;
    --tree-indent: 16px;
}

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

body {
    font-family: var(--font-family);
    background: var(--deep-blue);
    color: var(--white);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 50%, rgba(0, 229, 255, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.25);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 229, 255, 0.45);
}

/* --- 3. Header --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(13, 27, 42, 0.9);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--cyan-glass-border);
    z-index: var(--z-header);
    display: flex;
    align-items: center;
}

.header-inner {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    height: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.sidebar-toggle {
    display: flex;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    border-color: var(--cyan-glass-border-strong);
    color: var(--vibrant-cyan);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}
.sidebar-toggle svg.flipped {
    transform: rotate(180deg);
}

.home-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: var(--font-size-small);
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: var(--transition);
    padding: 6px 10px;
    border: 1px solid transparent;
}

.home-link:hover {
    color: var(--vibrant-cyan);
    border-color: var(--cyan-glass-border);
}

.home-link svg {
    width: 16px;
    height: 16px;
}

.brand-btn {
    background: transparent;
    border: none;
    font-family: 'Oxanium', var(--font-family);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    cursor: pointer;
    background: linear-gradient(90deg, var(--vibrant-cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 4px 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid var(--cyan-glass-border-strong);
    color: var(--white);
    font-family: var(--font-family);
    font-size: var(--font-size-small);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
}

.header-btn:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: var(--shadow-glow-cyan);
}

.header-btn svg {
    width: 16px;
    height: 16px;
}

/* --- Notification Bell + Panel --- */
.notification-bell {
    position: relative;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.notification-bell:hover {
    border-color: rgba(0, 229, 255, 0.4);
    color: #00E5FF;
    background: rgba(0, 229, 255, 0.06);
}

.notification-bell svg {
    width: 18px;
    height: 18px;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #F43F5E;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border: 1px solid rgba(13, 27, 42, 1);
    box-sizing: border-box;
}

@keyframes notification-bell-pulse {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.18); }
    70%  { transform: scale(0.96); }
    100% { transform: scale(1); }
}

.notification-bell-pulse {
    animation: notification-bell-pulse 0.6s ease;
}

.notification-panel {
    position: absolute;
    top: calc(var(--header-height) - 4px);
    right: 12px;
    width: 360px;
    max-width: calc(100vw - 24px);
    max-height: 60vh;
    background: rgba(13, 27, 42, 0.97);
    border: 1px solid rgba(0, 229, 255, 0.25);
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    flex-direction: column;
}

/* Honor the HTML `hidden` attribute. Without this, the `display: flex` above
   overrides the browser UA default of `display: none` for [hidden], leaving
   the empty panel permanently visible. */
.notification-panel[hidden] {
    display: none;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.12);
    flex-shrink: 0;
}

.notification-panel-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.85);
}

.notification-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-clear-all {
    background: transparent;
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #F43F5E;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.notification-clear-all:hover {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.6);
}

.notification-panel-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    transition: color 0.15s;
}

.notification-panel-close:hover {
    color: #00E5FF;
}

.notification-panel-body {
    overflow-y: auto;
    padding: 4px 0;
}

.notification-empty {
    padding: 32px 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.notification-item:hover {
    background: rgba(0, 229, 255, 0.05);
}

.notification-item-main {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #E8E8E8;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.notification-item-project {
    color: rgba(0, 229, 255, 0.7);
}

.notification-item-clear {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.notification-item-clear:hover {
    color: #F43F5E;
}

.notification-load-more {
    width: 100%;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(0, 229, 255, 0.12);
    color: rgba(0, 229, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
    padding: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.notification-load-more:hover {
    background: rgba(0, 229, 255, 0.05);
    color: #00E5FF;
}

@media (max-width: 768px) {
    .notification-panel {
        width: calc(100vw - 16px);
        right: 8px;
    }
}

/* --- 4. Page Layout --- */
.page-content {
    padding-top: var(--header-height);
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

.app-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
}

/* --- 5. Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: rgba(13, 27, 42, 0.95);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: 1px solid var(--cyan-glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
    position: relative;
    z-index: var(--z-sidebar);
}

/* Desktop collapsed state — sidebar shrinks to 0 */
.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

/* --- 6. Project Selector (collapsible dropdown) --- */
.project-selector {
    flex-shrink: 0;
    position: relative;
}

.project-selector-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--glass-border);
    color: var(--white);
    cursor: pointer;
    font-family: var(--font-family);
    transition: var(--transition);
    text-align: left;
}

.project-selector-toggle:hover {
    background: rgba(0, 229, 255, 0.04);
}

.project-selector-toggle .toggle-color-dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.project-selector-toggle .toggle-info {
    flex: 1;
    min-width: 0;
}

.project-selector-toggle .toggle-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    display: block;
    margin-bottom: 2px;
}

.project-selector-toggle .toggle-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.project-selector-toggle .toggle-chevron {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.project-selector-toggle .toggle-chevron svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.project-selector.open .toggle-chevron {
    transform: rotate(180deg);
}

.project-selector-toggle .toggle-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.sidebar-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-action-btn:hover {
    border-color: var(--cyan-glass-border-strong);
    color: var(--vibrant-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.sidebar-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Project dropdown panel */
.project-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    opacity: 0;
    border-bottom: 1px solid transparent;
}

.project-selector.open .project-dropdown {
    max-height: 320px;
    opacity: 1;
    border-bottom-color: var(--glass-border);
}

.project-dropdown-inner {
    padding: 8px;
}

.project-search {
    padding: 0 8px 8px;
}

.project-search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 12px;
    transition: var(--transition);
}

.project-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.project-search-input:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
    padding: 0 8px;
}

/* Project card in selector */
.project-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    width: 100%;
    text-align: left;
    font-family: var(--font-family);
    color: var(--white);
}

.project-card:hover {
    background: rgba(0, 229, 255, 0.06);
    border-color: var(--cyan-glass-border);
}

.project-card.active {
    background: rgba(0, 229, 255, 0.12);
    border-color: var(--cyan-glass-border-strong);
}

.project-card.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--vibrant-cyan);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.project-color-dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.project-card-info {
    flex: 1;
    min-width: 0;
}

.project-card-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card-count {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.project-card-subtitle {
    font-size: 10px;
    color: rgba(139, 92, 246, 0.75);
    margin-top: 2px;
    letter-spacing: 0.3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-list-section-header {
    padding: 14px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- 7. Sidebar Divider --- */
.sidebar-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--cyan-glass-border) 50%, transparent 100%);
    margin: 0;
    flex-shrink: 0;
}

/* --- 8. Project Tree Section --- */
.project-tree-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tree-project-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.tree-actions {
    display: flex;
    gap: 4px;
}

.tree-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: var(--transition);
}

.tree-action-btn:hover {
    border-color: var(--glass-border);
    color: rgba(255, 255, 255, 0.8);
}

.tree-action-btn svg {
    width: 14px;
    height: 14px;
}

.tree-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(56, 194, 249, 0.3);
    color: #38C2F9;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}
.tree-add-btn:hover {
    background: rgba(56, 194, 249, 0.1);
    border-color: rgba(56, 194, 249, 0.5);
}
.tree-add-btn svg {
    width: 15px;
    height: 15px;
}

/* Tree search */
.tree-search {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-search-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(56, 194, 249, 0.5);
    border: 1px solid rgba(56, 194, 249, 0.3);
    border-radius: 50%;
    cursor: help;
    flex-shrink: 0;
}

.tree-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 12px;
    transition: var(--transition);
}

.tree-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.tree-search-input:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

/* Tree container */
.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* --- 9. Tree Nodes --- */
.tree-node {
    user-select: none;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    cursor: pointer;
    transition: background 0.1s ease, transform 0.1s ease;
    position: relative;
    min-height: 32px;
}

.tree-node-row:hover {
    background: rgba(0, 229, 255, 0.06);
}

.tree-node-row.selected {
    background: rgba(0, 229, 255, 0.15);
}

.tree-node-row.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--vibrant-cyan);
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

.tree-node-row.focused {
    outline: 1px solid rgba(0, 229, 255, 0.4);
    outline-offset: -1px;
}

/* Drag and Drop */
.tree-node-row.dragging {
    opacity: 0.35;
}

.tree-node-row.drop-before {
    box-shadow: 0 -2px 0 0 #38C2F9;
}

.tree-node-row.drop-inside {
    outline: 1px solid #38C2F9;
    background: rgba(56, 194, 249, 0.1);
}

.tree-node-row.drop-after {
    box-shadow: 0 2px 0 0 #38C2F9;
}

/* Move-to modal */
.move-to-container {
    min-width: 300px;
}

.move-to-tree {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 0;
}

.move-to-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    transition: background 0.1s ease;
}

.move-to-item:hover {
    background: rgba(0, 229, 255, 0.06);
}

.move-to-item.selected {
    background: rgba(0, 229, 255, 0.15);
    color: #fff;
}

.move-to-item .tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.move-to-item .tree-icon svg {
    width: 16px;
    height: 16px;
}

/* Expand chevron */
.tree-expand {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.15s ease;
}

.tree-expand svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.tree-expand.expanded {
    transform: rotate(90deg);
}

.tree-expand-spacer {
    width: 16px;
    flex-shrink: 0;
}

/* Tree icon */
.tree-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tree-icon svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.tree-icon.folder-icon {
    color: var(--vibrant-cyan);
}

.tree-icon.conversation-icon {
    color: var(--purple);
}

.tree-icon.note-icon {
    color: var(--success);
}

.tree-icon.file-icon {
    color: var(--warning);
}

.tree-icon.site-icon {
    color: #3B82F6;
}

.tree-icon.task-icon {
    color: #F43F5E;
}

/* Tree label */
.tree-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.85);
}

.tree-node-row.selected .tree-label {
    color: var(--white);
}

/* Tree item menu (three dots) */
.tree-item-menu {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.tree-node-row:hover .tree-item-menu {
    opacity: 1;
}

.tree-item-menu:hover {
    color: var(--vibrant-cyan);
}

.tree-item-menu svg {
    width: 14px;
    height: 14px;
}

/* Tree children */
.tree-node-children {
    overflow: hidden;
}

.tree-node-children.collapsed {
    display: none;
}

/* Tree inline rename */
.tree-rename-input {
    flex: 1;
    padding: 2px 6px;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid var(--cyan-glass-border-strong);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
}

.tree-rename-input:focus {
    outline: none;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

/* Tree empty state */
.tree-empty {
    padding: 32px 20px;
    text-align: center;
}

.tree-empty-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: rgba(255, 255, 255, 0.2);
}

.tree-empty-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.tree-empty-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
}

/* --- 10. Content Panel --- */
.content-panel {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    background: var(--deep-blue);
}

.content-wrapper {
    flex: 1;
    min-width: 0;
    padding: 32px 40px;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.content-wrapper > *:first-child {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* --- 11. Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    color: rgba(0, 229, 255, 0.25);
    animation: float 3s ease-in-out infinite;
}

.empty-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1;
    fill: none;
}

.empty-title {
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--vibrant-cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.empty-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.45);
    max-width: 380px;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* Centered search state (sidebar collapsed = HyperSearch feel) */
.search-landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 40px;
    text-align: center;
    min-height: 60vh;
}
/* Barnaby landing — matches HyperSearch layout */
.barnaby-inline-avatar {
    display: flex;
    justify-content: center;
    padding: 4px 0 12px 0;
    pointer-events: none;
}
.barnaby-inline-avatar img {
    width: 55px;
    height: auto;
    opacity: 0.85;
    filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.3));
}
.barnaby-message-wrapper.barnaby-proactive {
    width: 100%;
    max-width: 600px;
    margin-bottom: 8px;
}
.message.barnaby {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.7;
    text-align: center;
}
.barnaby-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    margin-bottom: 24px;
    justify-content: center;
    width: 100%;
    max-width: 600px;
}
.barnaby-button {
    background: rgba(13, 27, 42, 0.95);
    color: var(--vibrant-cyan, #38C2F9);
    border: 2px solid rgba(0, 229, 255, 0.7);
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2), inset 0 1px 0 rgba(0, 229, 255, 0.1);
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    letter-spacing: 0.5px;
}
.barnaby-button:hover {
    background: rgba(0, 229, 255, 0.15);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.4), inset 0 1px 0 rgba(0, 229, 255, 0.2);
    transform: translateY(-1px);
}
.search-landing-input-wrap {
    width: 100%;
    max-width: 600px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Barnaby orb toggle (left of search input) */
.barnaby-orb-toggle {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}
.barnaby-orb-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s;
}
.barnaby-orb-toggle.active .barnaby-orb-dot {
    background: var(--vibrant-cyan, #38C2F9);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.6), 0 0 24px rgba(0, 229, 255, 0.3);
    animation: orbPulse 2s ease-in-out infinite;
}
@keyframes orbPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(0, 229, 255, 0.6), 0 0 24px rgba(0, 229, 255, 0.3); }
    50% { box-shadow: 0 0 18px rgba(0, 229, 255, 0.8), 0 0 36px rgba(0, 229, 255, 0.4); }
}
.barnaby-orb-toggle:hover .barnaby-orb-dot {
    transform: scale(1.2);
}
/* Smaller orb in conversation input bar — aligned with input */
.barnaby-orb-toggle.conv-orb {
    width: 32px;
    height: 32px;
    border: none;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 8px;
}
.barnaby-orb-toggle.conv-orb .barnaby-orb-dot {
    width: 10px;
    height: 10px;
}
.search-landing-input-inner {
    flex: 1;
    position: relative;
    min-width: 0;
}
.search-landing-input {
    width: 100%;
    padding: 14px 50px 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--cyan-glass-border);
    color: var(--white);
    font-size: 15px;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Textarea support: auto-grow, no manual resize */
    resize: none;
    overflow: hidden;
    line-height: 1.4;
    min-height: 48px;
    box-sizing: border-box;
}
.search-landing-input:focus {
    border-color: var(--vibrant-cyan);
    box-shadow: 0 0 20px rgba(56, 194, 249, 0.15);
}
.search-landing-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}
.search-landing-send {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: var(--vibrant-cyan);
    color: var(--deep-blue);
    border: none;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.search-landing-send:hover {
    background: #5dd4ff;
}
.search-landing-space-indicator {
    margin-top: 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
}
.search-landing-space-indicator:hover {
    color: var(--vibrant-cyan);
}

/* --- 12. Buttons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border: 1px solid var(--cyan-glass-border-strong);
    color: var(--white);
    font-family: var(--font-family);
    font-size: var(--font-size-small);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: var(--shadow-glow-cyan);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary svg {
    width: 16px;
    height: 16px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-family);
    font-size: var(--font-size-small);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border-strong);
    color: var(--white);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    font-family: var(--font-family);
    font-size: var(--font-size-small);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    border-color: var(--cyan-glass-border-strong);
    color: var(--vibrant-cyan);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* --- 13. Project Detail View --- */
.detail-header {
    margin-bottom: 32px;
}

/* Title row: title + Share Space button side-by-side on the Space detail
   page. Title takes up available width, Share button sits flush right. */
.detail-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-title-row .detail-title {
    flex: 1;
    width: auto;
}

.project-share-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.project-share-btn svg {
    width: 14px;
    height: 14px;
}

.detail-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--white);
    border: none;
    background: transparent;
    outline: none;
    padding: 4px 0;
    display: block;
    width: 100%;
    min-height: 40px;
}

.detail-title:focus {
    border-bottom: 1px solid var(--cyan-glass-border-strong);
}

.detail-title[contenteditable="true"]:hover {
    border-bottom: 1px solid var(--glass-border);
}

.detail-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 4px;
}

/* Description */
.detail-description {
    margin-bottom: 28px;
}

.desc-textarea,
.instructions-textarea {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition);
    min-height: 60px;
}

.desc-textarea::placeholder,
.instructions-textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.desc-textarea:focus,
.instructions-textarea:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
}

/* Project save row */
.project-save-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
}

.project-save-row .btn-primary {
    padding: 8px 20px;
    font-size: 13px;
}

.save-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* Instructions section */
.instructions-section {
    margin-bottom: 32px;
    padding: 20px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.15);
}

.instructions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.instructions-header h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--purple);
}

.instructions-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
}

.instructions-icon {
    width: 18px;
    height: 18px;
    color: var(--purple);
}

.instructions-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.instructions-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: rgba(56, 194, 249, 0.7);
    padding: 2px 8px;
    background: rgba(56, 194, 249, 0.08);
    cursor: help;
}

.instructions-active-badge svg {
    width: 12px;
    height: 12px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 16px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--cyan-glass-border);
    transform: translateY(-2px);
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--vibrant-cyan);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.4);
}

/* Quick actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-card:hover {
    background: rgba(0, 229, 255, 0.06);
    border-color: var(--cyan-glass-border);
    border-style: solid;
    color: var(--white);
}

.action-card svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    transition: var(--transition);
}

.action-card:hover svg {
    color: var(--vibrant-cyan);
}

/* Activity feed */
.activity-section h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    transition: var(--transition);
}

.activity-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.activity-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.activity-text {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.activity-text strong {
    color: var(--white);
    font-weight: 600;
}

.activity-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Danger zone (delete project) */
.danger-zone {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 60, 60, 0.15);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 60, 60, 0.3);
    color: rgba(255, 80, 80, 0.8);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: rgba(255, 60, 60, 0.1);
    border-color: rgba(255, 60, 60, 0.5);
    color: #ff4444;
}

.btn-danger svg {
    width: 14px;
    height: 14px;
}

/* --- 14. Folder Detail View --- */
.folder-contents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.folder-item-card {
    padding: 16px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.folder-item-card:hover {
    background: rgba(0, 229, 255, 0.06);
    border-color: var(--cyan-glass-border);
    transform: translateY(-2px);
}

.folder-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
}

.folder-item-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.folder-item-info {
    flex: 1;
    min-width: 0;
}

.folder-item-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.folder-item-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
}

/* --- 15. Conversation Detail View --- */
.conversation-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.meta-badge {
    display: inline-flex;
    padding: 4px 10px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    font-size: 11px;
    font-weight: 600;
    color: var(--purple);
    letter-spacing: 0.5px;
}

.meta-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
}

.messages-list {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    padding: 16px 20px;
    border-left: 3px solid;
    animation: fadeIn 0.3s ease;
}

.message-user {
    background: rgba(0, 229, 255, 0.06);
    border-color: var(--vibrant-cyan);
}

.message-ai {
    background: rgba(139, 92, 246, 0.06);
    border-color: var(--purple);
}

.message-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.message-user .message-role {
    color: var(--vibrant-cyan);
}

.message-ai .message-role {
    color: var(--purple);
}

/* Shared-thread author attribution: messages from the OTHER participant
   render with a violet border + violet role label so the viewer can tell
   at a glance who sent what. */
.message-user.message-from-other {
    background: rgba(139, 92, 246, 0.06);
    border-color: var(--purple);
}

.message-user.message-from-other .message-role {
    color: var(--purple);
    text-transform: none;
    letter-spacing: 0.5px;
    font-weight: 600;
    font-size: 11px;
}

/* Permission toggle in the share modal — segmented control with both
   options visible at once. Active pill has a cyan accent. */
.permission-toggle {
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.permission-toggle .perm-option {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 18px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.permission-toggle .perm-option + .perm-option {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.permission-toggle .perm-option:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--white);
}

.permission-toggle .perm-option.active {
    background: rgba(0, 229, 255, 0.12);
    color: var(--vibrant-cyan);
    font-weight: 600;
}

/* "Forked from <user>" badge — shown above the title on items the user
   has forked from someone else's share. Click the user → opens the source
   public viewer in a new tab. Click × → hides the attribution on this fork
   (per Decision #19, recipient can remove). */
.fork-attribution {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin: 8px 0 0;
    background: rgba(139, 92, 246, 0.08);
    border-left: 2px solid var(--purple);
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.fork-attribution-prefix { color: rgba(255, 255, 255, 0.5); font-weight: 500; }
.fork-attribution-link { color: var(--purple); text-decoration: none; font-weight: 600; }
.fork-attribution-link:hover { color: var(--electric-cyan); text-decoration: underline; }
.fork-attribution-remove {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    margin-left: 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}
.fork-attribution:hover .fork-attribution-remove { opacity: 1; }
.fork-attribution-remove:hover { color: var(--vibrant-cyan); }

/* Delete-my-message button rendered inline with the role label for the
   viewer's own messages in shared conversations. Stays subtle; only
   visible on hover so it doesn't compete with the content. */
.message-delete-mine {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.35);
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.message-user:hover .message-delete-mine {
    opacity: 1;
}

.message-delete-mine:hover {
    color: var(--vibrant-cyan);
}

.message-content {
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
}

.message-content strong {
    color: var(--white);
    font-weight: 600;
}

.message-content code {
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Typing indicator animation */
.typing-dots span {
    animation: typingDot 1.4s infinite;
    opacity: 0.3;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* Stream milestones (real-time LTM progress) */
.stream-milestones {
    padding: 12px 16px;
    margin: 8px 0;
    border-left: 2px solid var(--cyan, #38C2F9);
    opacity: 1;
    transition: opacity 0.6s ease;
}
.stream-milestones.milestones-fade { opacity: 0; }
.stream-milestone {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    padding: 3px 0;
    transition: color 0.3s ease;
}
.stream-milestone.active {
    color: rgba(255, 255, 255, 0.7);
}
.stream-milestone.done {
    color: rgba(56, 194, 249, 0.8);
}
.milestone-check {
    color: var(--cyan, #38C2F9);
    margin-left: 4px;
}

/* Sidebar mode toggle (Tree / Recent) */
.sidebar-mode-toggle {
    display: flex;
    gap: 2px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--glass-border);
}
.mode-btn {
    flex: 1;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    transition: all 0.2s;
}
.mode-btn:hover { color: rgba(255,255,255,0.7); }
.mode-btn.active {
    color: var(--vibrant-cyan, #38C2F9);
    border-color: var(--cyan-glass-border);
    background: rgba(56, 194, 249, 0.08);
}

/* Recent mode scope toggle (This Space / All Spaces) */
.recent-scope-toggle {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--glass-border);
}
.recent-scope-btn {
    flex: 1;
    padding: 4px 6px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    font-size: 11px;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.2s;
    text-align: center;
}
.recent-scope-btn:hover { color: rgba(255,255,255,0.7); }
.recent-scope-btn.active {
    color: var(--vibrant-cyan, #38C2F9);
    border-color: var(--cyan-glass-border);
    background: rgba(56, 194, 249, 0.08);
}
.recent-item-space {
    color: rgba(56, 194, 249, 0.5);
    font-size: 10px;
}

/* Recent mode items */
.recent-container { overflow-y: auto; flex: 1; padding: 4px 0; }
.recent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.recent-item:hover { background: rgba(255,255,255,0.05); }
.recent-item.selected { background: rgba(56, 194, 249, 0.1); }
.recent-item-icon { color: rgba(255,255,255,0.4); flex-shrink: 0; width: 16px; }
.recent-item-info { flex: 1; min-width: 0; }
.recent-item-name {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-item-date { font-size: 11px; color: rgba(255,255,255,0.3); }
.recent-item-menu {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.recent-item:hover .recent-item-menu { opacity: 1; }
.recent-item-menu:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.1); }
.recent-rename-input {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--vibrant-cyan, #38C2F9);
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    padding: 2px 6px;
    outline: none;
}

/* Inline source links (used by simpleMarkdown for all hyperlinks) */
.inline-source-link {
    color: #38C2F9;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin: 0 1px;
}
.inline-source-link:hover {
    color: #5dd4ff;
}

/* Superscript citation links (Gemini [[SOURCE X]] → Wikipedia-style ¹²³) */
.citation-superscript {
    color: var(--vibrant-cyan, #38C2F9);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}
.citation-superscript:hover {
    color: var(--electric-cyan, #5dd4ff);
    text-decoration: underline;
}

/* Barnaby landing inside conversation (matches search landing layout) */
.search-landing-inline {
    padding: 30px 20px 20px;
    min-height: auto;
}

/* Barnaby greeting */
.barnaby-greeting {
    border-left: 2px solid var(--vibrant-cyan, #38C2F9);
    opacity: 0.7;
}
.barnaby-greeting .message-role {
    color: var(--vibrant-cyan, #38C2F9);
}

/* Error message styling */
.message-error .message-role {
    color: var(--danger);
}
.message-error .message-content {
    color: var(--danger);
    font-style: italic;
}

/* Tag badges in conversation */
.tag-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tag-badge {
    padding: 3px 8px;
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid var(--cyan-glass-border);
    font-size: 10px;
    font-weight: 600;
    color: rgba(0, 229, 255, 0.7);
    letter-spacing: 0.5px;
}

/* --- 16. Note Detail View --- */
.note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.note-content {
    margin-top: 24px;
    font-size: 14px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.85);
}

.note-content h1,
.note-content h2,
.note-content h3 {
    color: var(--white);
    margin-top: 24px;
    margin-bottom: 12px;
}

.note-content h1 {
    font-size: 22px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
}

.note-content h2 {
    font-size: 18px;
}

.note-content h3 {
    font-size: 15px;
}

.note-content ul,
.note-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

.note-content li {
    margin: 4px 0;
}

.note-content p {
    margin: 8px 0;
}

.note-content strong {
    color: var(--white);
}

.note-content code {
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.note-content pre {
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    overflow-x: auto;
    margin: 12px 0;
}

.note-content pre code {
    background: transparent;
    padding: 0;
}

.note-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.note-save-status {
    font-size: 12px;
    color: rgba(56, 194, 249, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.note-save-status.visible {
    opacity: 1;
}

/* --- 17. File Detail View --- */
.file-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 32px;
}

.file-icon-large {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    margin-bottom: 16px;
}

.file-icon-large svg {
    width: 40px;
    height: 40px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.file-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.file-meta-item {
    padding: 14px;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    text-align: center;
}

.file-meta-item .label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 6px;
}

.file-meta-item .value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
}

.file-preview {
    padding: 40px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

/* --- 18. Context Menu --- */
.context-menu {
    position: fixed;
    min-width: 180px;
    background: rgba(13, 27, 42, 0.98);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--cyan-glass-border-strong);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), var(--shadow-glow-cyan);
    z-index: var(--z-context-menu);
    display: none;
    padding: 6px 0;
}

.context-menu.active {
    display: block;
    animation: fadeIn 0.15s ease;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: var(--transition);
}

.context-menu-item:hover {
    background: rgba(0, 229, 255, 0.1);
    color: var(--white);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.context-menu-item svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    flex-shrink: 0;
}

.context-menu-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 4px 0;
}

/* --- 19. Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: var(--z-overlay);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: rgba(13, 27, 42, 0.98);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 2px solid var(--cyan-glass-border-strong);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.2), 0 8px 32px rgba(0, 0, 0, 0.6);
    padding: 32px;
    width: 420px;
    max-width: 90vw;
    animation: slideDown 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
}

.modal-close:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.modal-body {
    margin-bottom: 24px;
}

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

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 14px;
    transition: var(--transition);
}

.form-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.form-select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option {
    background: var(--deep-blue);
    color: var(--white);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* --- 20. Meta Conversation Panel (inline — mobile fallback) --- */
/* Hidden on desktop (side panel used instead), shown on mobile */
@media (min-width: 769px) {
    .meta-conversation {
        display: none !important;
    }
}

.meta-conversation {
    margin-top: 32px;
    border: 1px solid var(--glass-border);
    transition: var(--transition-slow);
}

.meta-conversation.has-messages {
    border-color: var(--cyan-glass-border);
}

.meta-conversation-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: var(--transition);
}

.meta-conversation-toggle:hover {
    background: rgba(0, 229, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
}

.meta-conversation-toggle .meta-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.meta-conversation-toggle .meta-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.meta-conversation-toggle .meta-badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid var(--cyan-glass-border);
    font-size: 10px;
    font-weight: 700;
    color: var(--vibrant-cyan);
    margin-left: auto;
}

.meta-conversation-toggle .meta-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.meta-conversation-toggle .meta-chevron svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.meta-conversation.open .meta-conversation-toggle .meta-chevron {
    transform: rotate(180deg);
}

.meta-conversation-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.meta-conversation.open .meta-conversation-body {
    max-height: 600px;
    overflow-y: auto;
}

.meta-messages {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta-message {
    padding: 10px 14px;
    border-left: 2px solid;
    font-size: 13px;
    line-height: 1.6;
}

.meta-message.meta-user {
    background: rgba(0, 229, 255, 0.04);
    border-color: rgba(0, 229, 255, 0.4);
}

.meta-message.meta-ai {
    background: rgba(139, 92, 246, 0.04);
    border-color: rgba(139, 92, 246, 0.4);
}

.meta-message-role {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.meta-user .meta-message-role { color: var(--vibrant-cyan); }
.meta-ai .meta-message-role { color: var(--purple); }

.meta-message-text {
    color: rgba(255, 255, 255, 0.8);
}

/* ==================== SITE CONVERSATION MODE ==================== */
.site-conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.1);
    flex-shrink: 0;
    gap: 12px;
}
.site-conv-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
}
.site-conv-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
.site-conv-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: default;
}
.site-conv-status.live { background: #10B981; }
.site-conv-status.draft { background: #F59E0B; }
.site-conv-url {
    font-size: 11px;
    color: rgba(56, 194, 249, 0.5);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.site-conv-url:hover { color: rgba(56, 194, 249, 0.9); }
.site-conv-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.site-conv-tabs {
    display: flex;
    gap: 0;
    margin-right: 4px;
}
.site-conv-tab {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.15s;
}
.site-conv-tab:first-child { border-radius: 4px 0 0 4px; }
.site-conv-tab:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.site-conv-tab.active {
    background: rgba(56, 194, 249, 0.15);
    color: #38C2F9;
    border-color: rgba(56, 194, 249, 0.3);
}
.site-conv-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
}
.site-conv-header-right .btn-secondary,
.site-conv-header-right .btn-primary {
    padding: 5px 12px;
    font-size: 11px;
}
.site-conv-header-right .btn-undo-toolbar {
    padding: 5px 10px;
    font-size: 11px;
}
.site-conv-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.site-conv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.6;
}
.site-conv-msg {
    max-width: 85%;
    padding: 12px 16px;
}
.site-conv-msg.site-conv-user {
    align-self: flex-end;
    background: rgba(56, 194, 249, 0.1);
    border: 1px solid rgba(56, 194, 249, 0.15);
    border-radius: 12px 12px 2px 12px;
}
.site-conv-msg.site-conv-ai {
    align-self: flex-start;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 12px 12px 12px 2px;
}
.site-conv-msg-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.site-conv-user .site-conv-msg-role { color: #38C2F9; }
.site-conv-ai .site-conv-msg-role { color: #8B5CF6; }
.site-conv-msg-text {
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
    word-wrap: break-word;
}
.site-conv-msg-text a { color: #38C2F9; }
.site-conv-msg-text p { margin: 0.5em 0; }
.site-conv-typing .site-conv-msg-text {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}
.site-conv-input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid rgba(0, 229, 255, 0.1);
    flex-shrink: 0;
}
.site-conv-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
}
.site-conv-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 40vh;
    font-family: inherit;
}
.site-conv-textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}
.site-conv-attach-btn, .site-conv-send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.site-conv-attach-btn svg, .site-conv-send-btn svg {
    width: 20px;
    height: 20px;
}
.site-conv-attach-btn { color: rgba(255, 255, 255, 0.3); }
.site-conv-attach-btn:hover { color: rgba(255, 255, 255, 0.6); }
.site-conv-send-btn { color: #38C2F9; }
.site-conv-send-btn:hover { color: #60D0FF; }

/* Site builder code mode layout */
.site-code-body {
    display: flex;
    gap: 20px;
    min-height: 500px;
}
.site-code-pagelist {
    width: 180px;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 229, 255, 0.1);
    padding-right: 16px;
}
.site-code-editor {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .site-conv-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .site-conv-header-right { flex-wrap: wrap; }
    .site-conv-msg { max-width: 95%; }
    .site-conv-url { display: none; }

    /* Site builder code mode — stack page list above editor */
    .site-code-body {
        flex-direction: column;
        gap: 12px;
        min-height: auto;
    }
    .site-code-pagelist {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(0, 229, 255, 0.1);
        padding-right: 0;
        padding-bottom: 12px;
    }
}

.meta-image-preview {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    flex-wrap: wrap;
}
.meta-image-thumb {
    position: relative;
    display: inline-block;
}
.meta-image-thumb img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.meta-image-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: rgba(255, 50, 50, 0.8);
    color: white;
    border: none;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.meta-message-images {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.meta-attached-image {
    max-width: 200px;
    max-height: 150px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-undo-toolbar {
    padding: 6px 14px;
    font-size: 12px;
    background: rgba(255, 165, 0, 0.1);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.25);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-undo-toolbar:hover {
    background: rgba(255, 165, 0, 0.2);
    border-color: rgba(255, 165, 0, 0.4);
}
.btn-undo-toolbar:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-undo-site-edit {
    margin-top: 8px;
    padding: 5px 14px;
    font-size: 11px;
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-undo-site-edit:hover {
    background: rgba(255, 165, 0, 0.25);
    border-color: rgba(255, 165, 0, 0.5);
}
.btn-undo-site-edit:disabled {
    opacity: 0.5;
    cursor: default;
}
.btn-undo-site-edit.btn-undo-done {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
    cursor: default;
}

.meta-empty {
    padding: 20px 16px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

.meta-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border);
}

.meta-input {
    flex: 1;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 13px;
    transition: var(--transition);
}

.meta-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.meta-input:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.1);
}

.meta-send-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid var(--cyan-glass-border-strong);
    color: var(--vibrant-cyan);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.meta-send-btn:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.3), rgba(139, 92, 246, 0.3));
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

.meta-send-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* --- 20b. Meta Side Panel (Desktop) --- */
.meta-side-panel {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-left: 1px solid transparent;
    background: rgba(1, 13, 26, 0.97);
    transition: width 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.meta-side-panel.open {
    width: 360px;
    border-left-color: var(--glass-border);
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.3);
}

.meta-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.meta-panel-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.5);
}

.meta-panel-icon svg {
    width: 100%;
    height: 100%;
}

.meta-panel-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.meta-panel-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid var(--cyan-glass-border);
    font-size: 10px;
    font-weight: 700;
    color: var(--vibrant-cyan);
    margin-left: auto;
}

.meta-panel-badge:empty,
.meta-panel-badge[data-count="0"] {
    display: none;
}

.meta-panel-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.meta-panel-close:hover {
    color: var(--vibrant-cyan);
    border-color: var(--cyan-glass-border-strong);
    background: rgba(0, 229, 255, 0.08);
}

.meta-panel-close svg {
    width: 18px;
    height: 18px;
}

.meta-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta-panel-messages .meta-message {
    padding: 10px 14px;
    border-left: 2px solid;
    font-size: 13px;
    line-height: 1.6;
}

.meta-panel-messages .meta-message.meta-user {
    background: rgba(0, 229, 255, 0.04);
    border-color: rgba(0, 229, 255, 0.4);
}

.meta-panel-messages .meta-message.meta-ai {
    background: rgba(139, 92, 246, 0.04);
    border-color: rgba(139, 92, 246, 0.4);
}

.meta-panel-messages .meta-message-role {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.meta-panel-messages .meta-message.meta-user .meta-message-role {
    color: var(--vibrant-cyan);
}

.meta-panel-messages .meta-message.meta-ai .meta-message-role {
    color: var(--purple);
}

.meta-panel-messages .meta-message-text {
    color: rgba(255, 255, 255, 0.8);
    word-wrap: break-word;
}

.meta-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 20px;
    text-align: center;
}

.meta-panel-empty-icon {
    width: 40px;
    height: 40px;
    color: rgba(255, 255, 255, 0.15);
    margin-bottom: 12px;
}

.meta-panel-empty-icon svg {
    width: 100%;
    height: 100%;
}

.meta-panel-empty-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.5;
}

.meta-panel-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.meta-panel-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 13px;
    transition: var(--transition);
}

.meta-panel-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.meta-panel-input:focus {
    outline: none;
    border-color: var(--cyan-glass-border-strong);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.1);
}

.meta-panel-send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid var(--cyan-glass-border-strong);
    color: var(--vibrant-cyan);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.meta-panel-send:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.3), rgba(139, 92, 246, 0.3));
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

.meta-panel-send svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Tab handle (collapsed state toggle) — always visible and prominent */
.meta-panel-tab {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 14px;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid var(--cyan-glass-border);
    border-right: none;
    color: rgba(0, 229, 255, 0.7);
    cursor: pointer;
    transition: var(--transition);
}

.meta-panel-tab:hover {
    background: rgba(0, 229, 255, 0.12);
    color: var(--vibrant-cyan);
    border-color: var(--cyan-glass-border-strong);
    box-shadow: -4px 0 16px rgba(0, 229, 255, 0.15);
}

.meta-tab-icon {
    width: 32px;
    height: 32px;
}

.meta-tab-icon svg {
    width: 100%;
    height: 100%;
}

.meta-tab-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--vibrant-cyan);
    line-height: 1;
}

.meta-tab-badge:empty {
    display: none;
}

/* Edge close button (left edge of open panel, vertically centered) */
.meta-panel-edge-close {
    position: absolute;
    right: 360px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 10px;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid var(--cyan-glass-border);
    border-right: none;
    color: rgba(0, 229, 255, 0.7);
    cursor: pointer;
    transition: opacity 0.3s ease, background 0.15s ease, color 0.15s ease;
    z-index: 11;
    opacity: 0;
    pointer-events: none;
}

.meta-side-panel.open ~ .meta-panel-edge-close {
    opacity: 1;
    pointer-events: auto;
}

.meta-panel-edge-close:hover {
    background: rgba(0, 229, 255, 0.12);
    color: var(--vibrant-cyan);
    border-color: var(--cyan-glass-border-strong);
    box-shadow: -4px 0 16px rgba(0, 229, 255, 0.15);
}

.meta-panel-edge-close svg {
    width: 28px;
    height: 28px;
}

/* Hide tab when panel is open */
.meta-side-panel.open ~ .meta-panel-tab {
    opacity: 0;
    pointer-events: none;
}

/* Hide side panel on mobile — use inline fallback */
@media (max-width: 768px) {
    .meta-side-panel,
    .meta-panel-tab,
    .meta-panel-edge-close {
        display: none !important;
    }
}

/* --- 21. Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

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

/* Skeleton loading placeholders */
.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    margin-bottom: 10px;
}
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.full { width: 100%; }

.skeleton-card {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.skeleton-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.skeleton-text {
    height: 12px;
    flex: 1;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin-bottom: 2px;
}
.skeleton-tree-icon {
    width: 16px;
    height: 16px;
    background: rgba(255,255,255,0.04);
    flex-shrink: 0;
}
.skeleton-tree-label {
    height: 12px;
    flex: 1;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-message {
    display: flex;
    gap: 10px;
    padding: 16px;
    margin-bottom: 8px;
}
.skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    flex-shrink: 0;
}
.skeleton-bubble {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* FTUE (First Time User Experience) */
.ftue-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}
.ftue-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    width: 170px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E8E8E8;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    text-align: center;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.ftue-card:hover {
    border-color: rgba(56, 194, 249, 0.5);
    background: rgba(56, 194, 249, 0.06);
    transform: translateY(-2px);
}
.ftue-card svg {
    color: #38C2F9;
}
.ftue-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #38C2F9;
}
.ftue-card-desc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.3;
}
/* FTUE card action buttons (info + clear) */
.ftue-card-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    z-index: 2;
}
.ftue-card-info,
.ftue-card-clear {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    line-height: 1;
}
.ftue-card:hover .ftue-card-info,
.ftue-card:hover .ftue-card-clear {
    opacity: 1;
}
.ftue-card-info {
    position: relative;
    background: rgba(56, 194, 249, 0.15);
    color: #38C2F9;
    font-style: italic;
    font-weight: 700;
}
.ftue-card-info:hover {
    background: rgba(56, 194, 249, 0.3);
}
.ftue-card-clear {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-style: normal;
}
.ftue-card-clear:hover {
    background: rgba(255, 80, 80, 0.2);
    color: #ff6666;
}

/* FTUE tooltip (appears above info button) */
.ftue-card-info::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 220px;
    padding: 10px 12px;
    background: rgba(1, 13, 26, 0.95);
    border: 1px solid rgba(56, 194, 249, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
}
.ftue-card-info:hover::after {
    opacity: 1;
}
.ftue-card.tooltip-visible .ftue-card-info {
    opacity: 1;
}
.ftue-card.tooltip-visible .ftue-card-info::after {
    opacity: 1;
    pointer-events: auto;
}

/* FTUE Clear All row */
.ftue-clear-all-row {
    text-align: center;
    margin-top: 4px;
}
.ftue-clear-all {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 4px 8px;
}
.ftue-clear-all:hover {
    color: rgba(255, 255, 255, 0.5);
}

/* Inline note cards (5D) */
.inline-note-cards {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.inline-note-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    max-width: 200px;
}
.inline-note-card:hover {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.15);
}
.inline-note-icon {
    color: #8B5CF6;
    flex-shrink: 0;
}
.inline-note-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick action buttons on AI responses */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    transition: color 0.15s, border-color 0.15s;
}
.quick-action-btn:hover {
    color: #38C2F9;
    border-color: rgba(56, 194, 249, 0.3);
}
.quick-action-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* FTUE visual highlight (subtle glow on target elements) */
.ftue-highlight {
    animation: ftueGlow 1.5s ease-in-out 2;
    position: relative;
    z-index: 10;
}
@keyframes ftueGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(56, 194, 249, 0); }
    50% { box-shadow: 0 0 20px rgba(56, 194, 249, 0.5), 0 0 40px rgba(56, 194, 249, 0.2); }
}

@media (max-width: 480px) {
    .ftue-cards {
        flex-direction: column;
        align-items: center;
    }
    .ftue-card {
        width: 100%;
        max-width: 250px;
    }
    .ftue-card-info,
    .ftue-card-clear {
        opacity: 1;
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 25px rgba(0, 229, 255, 0.4);
    }
}

/* --- 21. Responsive --- */
@media (max-width: 768px) {
    :root {
        --tree-indent: 12px;
    }

    /* Fixed positioning is the most reliable way to fill the visible viewport
       on mobile. 100vh/100dvh can include space behind the system nav bar,
       pushing the bottom off-screen. fixed + inset: 0 always matches the
       actual visible area. */
    .page-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .app-container {
        height: 100%;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: min(320px, 85vw);
        min-width: 0;
        z-index: var(--z-sidebar);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-height);
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-sidebar) - 1);
    }

    .sidebar-backdrop.active {
        display: block;
    }

    .content-wrapper {
        padding: 20px 16px;
    }

    .conversation-scroll-area {
        padding: 20px 16px;
    }

    .conversation-input-bar-container {
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .stats-grid,
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .file-meta-grid {
        grid-template-columns: 1fr;
    }

    .home-link span {
        display: none;
    }

    .header-btn span {
        display: none;
    }

    /* Move New Project button to left side so it doesn't overlap nav hamburger */
    .header-right {
        order: -1;
        justify-content: flex-start;
    }

    .header-left {
        order: 0;
    }

    /* Hide Barnaby orb on mobile — frees space for gear button to fit */
    .barnaby-orb-toggle {
        display: none;
    }


    /* Shrink gear button on mobile so it fits in the input row */
    .projects-gear-btn {
        width: 34px;
        height: 34px;
    }
    .projects-gear-btn svg {
        width: 18px;
        height: 18px;
    }

    .project-selector.open .project-dropdown {
        max-height: min(240px, 40vh);
    }
}

@media (max-width: 480px) {
    .detail-title {
        font-size: 22px;
    }

    .empty-title {
        font-size: 18px;
        letter-spacing: 2px;
    }

    .folder-contents-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 20px 16px;
        width: 95vw;
    }

    .personalization-body textarea {
        min-height: 150px;
    }
}

/* Touch device scrollbar */
@media (hover: none) and (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* ========================================
   CONVERSATION INPUT BAR & SETTINGS GEAR
   ======================================== */

/* --- Input Bar Container (conversation detail) --- */
/* --- Pinned conversation input: content-wrapper becomes flex column --- */
.content-wrapper.has-pinned-input {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.content-wrapper.has-pinned-input > *:first-child {
    max-width: none;
    margin: 0;
}

.conversation-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.conversation-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px 16px;
}

.conversation-scroll-area > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.conversation-input-bar-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 40px;
    background: transparent;
    flex-shrink: 0;
    max-width: 880px;   /* 800px content + 2×40px padding */
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.conversation-input-column {
    flex: 1;
    min-width: 0;  /* Allow shrinking so gear button stays visible */
    display: flex;
    flex-direction: column;
}

/* --- Shared Input Bar (used in both conversation + meta panel) --- */
.projects-input-bar {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(13, 27, 42, 0.85);
    border: 2px solid rgba(0, 229, 255, 0.4);
    min-height: 48px;
    transition: all 0.25s ease;
}

.projects-input-bar:focus-within {
    border-color: rgba(0, 229, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.2),
                0 0 40px rgba(0, 229, 255, 0.1);
}

/* Compact variant for meta panel */
.projects-input-bar.compact {
    min-height: 36px;
    border-width: 1px;
}

.projects-input-bar.compact .projects-attach-btn {
    padding: 0 10px;
    height: 36px;
}

.projects-input-bar.compact .projects-attach-btn svg {
    width: 15px;
    height: 15px;
}

.projects-input-bar.compact .projects-input {
    padding: 8px 10px;
    font-size: 13px;
}

.projects-input-bar.compact .projects-send-btn {
    width: 36px;
    height: 36px;
}

.projects-input-bar.compact .projects-send-btn svg {
    width: 13px;
    height: 13px;
}

/* --- Attachment Button (Paperclip) --- */
.projects-attach-btn {
    background: none;
    border: none;
    border-right: 1px solid rgba(0, 229, 255, 0.2);
    color: var(--vibrant-cyan);
    cursor: pointer;
    padding: 0 16px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.projects-attach-btn:hover {
    background: rgba(0, 229, 255, 0.08);
    color: var(--electric-cyan);
}

.projects-attach-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Text Input (textarea) --- */
.projects-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-family: var(--font-family);
    color: rgba(255, 255, 255, 0.95);
    outline: none;
    padding: 12px 16px;
    min-width: 0;
    resize: none;
    height: 38px;
    max-height: 120px;
    overflow-y: hidden;
    line-height: 1.4;
}

.projects-input::placeholder {
    color: rgba(0, 229, 255, 0.35);
}

/* Expanded textarea mode */
.projects-input.expanded {
    min-height: 80px;
    max-height: 200px;
}

.projects-input-bar.expanded {
    align-items: flex-end;
}

/* --- Expand Button --- */
.projects-expand-btn {
    width: 36px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-left: 1px solid rgba(0, 229, 255, 0.1);
    color: rgba(0, 229, 255, 0.5);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
}

.projects-expand-btn:hover {
    background: rgba(0, 229, 255, 0.08);
    color: var(--vibrant-cyan);
}

.projects-expand-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* --- Send Button --- */
.projects-send-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-left: 1px solid rgba(0, 229, 255, 0.2);
    color: var(--vibrant-cyan);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.projects-send-btn:hover {
    background: rgba(0, 229, 255, 0.1);
    color: var(--electric-cyan);
}

.projects-send-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* --- Gear Button --- */
.projects-gear-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(0, 229, 255, 0.7);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: relative;
}

.projects-gear-btn:hover {
    color: var(--vibrant-cyan);
}

.projects-gear-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Compact gear for meta panel */
.meta-panel-input-area .projects-gear-btn {
    width: 32px;
    height: 32px;
}

.meta-panel-input-area .projects-gear-btn svg {
    width: 18px;
    height: 18px;
}

/* --- Gear Popup / Flyout (horizontal — used by conversation input bar) --- */
.projects-gear-popup {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    background: rgba(13, 27, 42, 0.95);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(0, 229, 255, 0.3);
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                0 0 20px rgba(0, 229, 255, 0.15);
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s ease;
}

.projects-gear-popup.visible {
    visibility: visible;
    opacity: 1;
}

/* Item wrapper (holds item + secondary menu) */
.projects-gear-item-wrapper {
    position: relative;
}

/* Each setting item (default: icon-above-label column for horizontal popup) */
.projects-gear-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(13, 27, 42, 1);
    border: 1px solid rgba(0, 229, 255, 0.2);
    min-width: 48px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.projects-gear-item:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.projects-gear-item svg {
    width: 22px;
    height: 22px;
    fill: rgba(0, 229, 255, 0.8);
}

.projects-gear-item-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(0, 229, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* --- Secondary Selection Menus (default: pop above, horizontal row) --- */
.projects-secondary-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 27, 42, 0.95);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(0, 229, 255, 0.3);
    padding: 8px;
    gap: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 110;
    width: fit-content;
}

.projects-secondary-menu.visible {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.projects-secondary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: rgba(0, 229, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 13px;
    font-family: var(--font-family);
}

.projects-secondary-item:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.projects-secondary-item.selected {
    background: rgba(0, 229, 255, 0.2);
    border-color: rgba(0, 229, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

/* Model-name subtitle under each Power option (Conservative/Balanced/Powerful).
   Provider-dependent — see POWER_MODEL_MAP in projects.js. */
.projects-secondary-item-model {
    font-size: 10px;
    opacity: 0.55;
    letter-spacing: 0;
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    font-weight: normal;
}

/* Plain-text subtitle under each option (e.g. Privacy modes). Same dimming as
   the model subtitle but uses the regular sans-serif body font for readability. */
.projects-secondary-item-desc {
    font-size: 10px;
    opacity: 0.55;
    letter-spacing: 0;
    font-weight: normal;
}

/* --- Override meta-panel-input-area for new layout --- */
.meta-panel-input-area {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 10px 10px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    position: relative;
}

/* --- Meta panel gear popup: vertical layout with full-width items --- */
.meta-panel-input-area .projects-gear-popup {
    flex-direction: column;
    padding: 4px;
    gap: 0;
}

.meta-panel-input-area .projects-gear-item-wrapper {
    width: 100%;
}

.meta-panel-input-area .projects-gear-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Secondary menus pop left in meta panel (no room above in vertical layout) */
.meta-panel-input-area .projects-secondary-menu {
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
    top: 50%;
    right: calc(100% + 6px);
}

.meta-panel-input-area .projects-secondary-menu.visible {
    flex-direction: column;
    gap: 4px;
}

/* --- Personalization Modal --- */
.personalization-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    visibility: hidden;
    opacity: 0;
    transition: all 0.2s ease;
}

.personalization-modal-overlay.show {
    visibility: visible;
    opacity: 1;
}

.personalization-modal {
    width: 90%;
    max-width: 700px;
    background: rgba(13, 27, 42, 0.98);
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6),
                0 0 30px rgba(0, 229, 255, 0.15);
    display: flex;
    flex-direction: column;
}

.personalization-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.personalization-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.personalization-avatar {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.personalization-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    margin: 0;
    font-family: var(--font-family);
}

.personalization-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin: 4px 0 0;
    font-family: var(--font-family);
}

.personalization-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 28px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.personalization-close:hover {
    color: var(--white);
}

.personalization-body {
    padding: 24px;
}

.personalization-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 16px;
    font-family: var(--font-family);
}

.personalization-body textarea {
    width: 100%;
    min-height: 260px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--white);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.personalization-body textarea:focus {
    border-color: rgba(0, 229, 255, 0.6);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.1);
}

.personalization-body textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.personalization-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
}

.personalization-footer .btn-primary {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    background: var(--vibrant-cyan);
    color: var(--deep-blue);
    border: 2px solid var(--vibrant-cyan);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.personalization-footer .btn-primary:hover {
    background: var(--electric-cyan);
    border-color: var(--electric-cyan);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

.personalization-footer .btn-secondary {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    background: rgba(0, 229, 255, 0.1);
    color: var(--vibrant-cyan);
    border: 2px solid rgba(0, 229, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.personalization-footer .btn-secondary:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: var(--vibrant-cyan);
}

/* --- Toast --- */
.projects-toast-stack {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    max-width: 90vw;
}

.projects-toast {
    background: rgba(13, 27, 42, 0.95);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: var(--vibrant-cyan);
    padding: 10px 20px;
    font-size: 13px;
    font-family: var(--font-family);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* --- Receipt Line (metadata below AI response) --- */
.message-receipt {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 229, 255, 0.15);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.02em;
}

/* --- Inline links in AI response content --- */
.message-ai .inline-source-link {
    color: var(--vibrant-cyan);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}
.message-ai .inline-source-link:hover {
    color: var(--electric-cyan);
    text-decoration-thickness: 2px;
}
.message-ai .citation-superscript {
    color: var(--vibrant-cyan);
}
.message-ai .citation-superscript:hover {
    color: var(--electric-cyan);
}

/* --- Foldable Sources Section --- */
.sources-section {
    margin-top: 8px;
}

.sources-toggle {
    cursor: pointer;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    padding: 4px 0;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}
.sources-toggle:hover {
    color: rgba(255, 255, 255, 0.75);
}

.chevron {
    display: inline-block;
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}
.chevron.rotated {
    transform: rotate(90deg);
}

.sources-body {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}
.sources-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* --- Source groups inside the foldable body --- */
.sources-group {
    padding: 8px 0 4px 0;
}
.sources-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.numbered-source {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 2px 0;
    font-size: 0.8rem;
}
.source-number {
    color: rgba(255, 255, 255, 0.4);
    min-width: 18px;
}
.source-url {
    color: var(--vibrant-cyan);
    text-decoration: none;
    word-break: break-all;
    transition: color 0.2s ease;
}
.source-url:hover {
    color: var(--electric-cyan);
    text-decoration: underline;
}

/* --- Related Notes Badges --- */
.relevant-notes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 4px;
}
.relevant-note-badge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 2px 10px;
    font-size: 0.75rem;
}
.relevant-note-badge.clickable-note {
    cursor: pointer;
    transition: all 0.2s ease;
}
.relevant-note-badge.clickable-note:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================================
   Attachment Preview (images/documents in conversation input)
   ============================================================ */
.attachment-preview-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(56, 194, 249, 0.15);
    background: rgba(56, 194, 249, 0.03);
}

.image-preview-container,
.document-preview-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-height: 150px;
    overflow-y: auto;
}

.image-preview {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border: 2px solid rgba(56, 194, 249, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.image-preview img {
    display: block;
    max-width: 100px;
    max-height: 100px;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-preview-remove:hover {
    background: rgba(255, 0, 0, 0.9);
    color: white;
}

.document-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 28px 6px 10px;
    border: 2px solid rgba(56, 194, 249, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.doc-name {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Message Images (inline in conversation bubbles)
   ============================================================ */
.message-images {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message-image-container {
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(56, 194, 249, 0.3);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-image-container:hover {
    border-color: rgba(56, 194, 249, 0.6);
    transform: scale(1.02);
}

.message-image {
    display: block;
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
}

/* ==================== PROJECT SEARCH RESULTS ==================== */

.search-results-container {
    padding: 40px;
    max-width: 880px;
    margin: 0 auto;
}

.search-results-header {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 24px;
}

.search-results-section {
    margin-bottom: 24px;
}

.search-section-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(56, 194, 249, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.search-result-card {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(13, 27, 42, 0.6);
    border: 1px solid rgba(56, 194, 249, 0.1);
    border-left: 3px solid;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.search-result-card:hover {
    transform: translateX(2px);
    border-color: rgba(56, 194, 249, 0.3);
}

.search-result-card.keyword-match {
    border-left-color: rgba(16, 185, 129, 0.7);
}

.search-result-card.semantic-match {
    border-left-color: rgba(139, 92, 246, 0.7);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-result-title {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.match-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-type-badge.keyword-badge {
    color: rgba(16, 185, 129, 0.9);
    background: rgba(16, 185, 129, 0.1);
}

.match-type-badge.semantic-badge {
    color: rgba(139, 92, 246, 0.9);
    background: rgba(139, 92, 246, 0.1);
}

.relevance-badge {
    font-size: 10px;
    padding: 1px 6px;
    color: rgba(56, 194, 249, 0.8);
    background: rgba(56, 194, 249, 0.1);
}

.search-result-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 6px;
    line-height: 1.4;
}

.search-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.search-empty {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    text-align: center;
    padding: 40px 0;
}

/* ==================== AGENT PROGRESS ==================== */

.message-agent-progress {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--purple);
    padding: 16px 20px;
    border-left: 3px solid var(--purple);
    animation: fadeIn 0.3s ease;
}

.message-agent-progress .message-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    color: var(--purple);
}

.agent-progress-content {
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
}

.agent-status {
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.agent-condition-eval {
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    border-left: 2px solid var(--vibrant-cyan);
    background: rgba(0, 229, 255, 0.05);
}

.agent-condition-label {
    color: var(--vibrant-cyan);
    font-weight: 600;
    margin-right: 4px;
}

.agent-actions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.agent-action-item {
    font-size: 13px;
    padding: 2px 0;
    font-family: 'Courier New', monospace;
}

.agent-action-success {
    color: #4ade80;
}

.agent-action-failed {
    color: var(--danger);
}

.agent-action-starting {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.agent-action-substep {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}

.agent-progress-done .agent-status {
    font-style: normal;
}

/* Agent stop button row — sits above input bar */
.agent-stop-row {
    display: flex;
    justify-content: center;
    padding: 4px 0 8px;
}

.agent-stop-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.agent-stop-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
}

.agent-stop-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== TASK STYLES ==================== */

/* Quick-complete checkbox in tree */
.task-quick-complete {
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease;
}
.task-quick-complete:hover {
    transform: scale(1.2);
    color: #10B981 !important;
}

/* Tree node task states */
.tree-node-row.task-completed .tree-label {
    text-decoration: line-through;
    opacity: 0.5;
}
.tree-node-row.task-overdue .tree-label {
    color: #EF4444;
}

/* Task detail panel */
.task-detail {
    padding: 24px;
    max-width: 720px;
}

.task-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.task-title-row .detail-title {
    flex: 1;
}

.task-checkbox {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.task-checkbox:hover {
    transform: scale(1.15);
}
.task-checkbox svg {
    width: 28px;
    height: 28px;
}

.task-completed-title {
    text-decoration: line-through;
    opacity: 0.5;
}

.task-overdue-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #EF4444;
    background: rgba(239, 68, 68, 0.15);
    padding: 2px 8px;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

/* Task fields grid */
.task-fields-grid {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.task-field {
    flex: 1;
    min-width: 140px;
}

.task-field-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.task-field-select,
.task-field-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s ease;
}
.task-field-select:focus,
.task-field-input:focus {
    outline: none;
    border-color: var(--vibrant-cyan, #00E5FF);
}

.task-due-relative {
    font-size: 11px;
    margin-top: 4px;
}

/* Task description */
.task-description-section {
    margin-top: 20px;
}

.task-description-textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 12px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.15s ease;
}
.task-description-textarea:focus {
    outline: none;
    border-color: var(--vibrant-cyan, #00E5FF);
}
.task-description-textarea::placeholder {
    color: rgba(255,255,255,0.25);
}

/* Task action buttons */
.task-actions-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Agent task panel inside the task detail */
.agent-task-section {
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(0, 229, 255, 0.04);
    border: 1px solid rgba(0, 229, 255, 0.18);
}
.agent-task-header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.agent-task-icon {
    font-size: 18px;
    flex-shrink: 0;
}
.agent-task-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    user-select: none;
}
.agent-task-toggle-label input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(0, 229, 255, 0.5);
    background: transparent;
    cursor: pointer;
    position: relative;
    margin: 0;
}
.agent-task-toggle-label input[type="checkbox"]:checked {
    background: #00E5FF;
    border-color: #00E5FF;
}
.agent-task-toggle-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: -1px;
    width: 4px;
    height: 9px;
    border: solid #010D1A;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.agent-task-prompt {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: #E8E8E8;
    padding: 8px 10px;
    font-family: var(--font-family);
    font-size: 13px;
    line-height: 1.4;
    margin-top: 4px;
    resize: vertical;
}
.agent-task-prompt:focus {
    outline: none;
    border-color: rgba(0, 229, 255, 0.6);
}
.agent-task-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.agent-task-pause-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    user-select: none;
}
.agent-task-pause-toggle input[type="checkbox"] {
    appearance: none;
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    cursor: pointer;
    position: relative;
    margin: 0;
}
.agent-task-pause-toggle input[type="checkbox"]:checked {
    background: #F59E0B;
    border-color: #F59E0B;
}
.agent-task-run-now {
    font-size: 12px;
    padding: 6px 12px;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: #00E5FF;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.agent-task-run-now:hover:not(:disabled) {
    background: rgba(0, 229, 255, 0.2);
    border-color: rgba(0, 229, 255, 0.7);
}
.agent-task-run-now:disabled {
    opacity: 0.5;
    cursor: wait;
}
.agent-task-last-run {
    margin-top: 10px;
    font-size: 12px;
}
.agent-task-last-run-empty { color: rgba(255, 255, 255, 0.4); }
.agent-task-last-run-success { color: #10B981; }
.agent-task-last-run-failed { color: #EF4444; }
.agent-task-last-run-link {
    color: #00E5FF;
    text-decoration: underline;
    cursor: pointer;
}
.agent-task-last-run-link:hover { color: rgba(0, 229, 255, 0.8); }

/* Dashboard row indicators for agent tasks */
.task-list-item-agent .task-list-name {
    color: rgba(0, 229, 255, 0.95);
}
.task-list-agent-badge {
    margin-right: 6px;
    font-size: 14px;
    opacity: 0.9;
}
.task-list-paused-badge {
    margin-left: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 1px 6px;
}

.task-complete-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}
.task-complete-btn svg {
    width: 16px;
    height: 16px;
}

.task-uncomplete-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.task-uncomplete-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.task-delete-btn {
    margin-left: auto;
}
.task-delete-btn svg {
    width: 14px;
    height: 14px;
}

/* Reminder chips */
.task-reminder-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.6);
    padding: 3px 8px;
    font-size: 11px;
}
.task-reminder-remove {
    cursor: pointer;
    color: rgba(255,255,255,0.3);
    font-size: 14px;
    line-height: 1;
}
.task-reminder-remove:hover {
    color: #EF4444;
}

/* My Tasks Dashboard */
.my-tasks-dashboard {
    padding: 24px;
    max-width: 800px;
}

.my-tasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.my-tasks-filters {
    display: flex;
    gap: 4px;
}

.my-tasks-filter-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.my-tasks-filter-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
}
.my-tasks-filter-btn.active {
    background: rgba(0,229,255,0.12);
    border-color: rgba(0,229,255,0.3);
    color: var(--vibrant-cyan, #00E5FF);
}

.my-tasks-search {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    width: 180px;
}
.my-tasks-search:focus {
    outline: none;
    border-color: var(--vibrant-cyan, #00E5FF);
}
.my-tasks-search::placeholder {
    color: rgba(255,255,255,0.25);
}

.my-tasks-toggle-done {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    user-select: none;
}
.my-tasks-toggle-done input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(0, 229, 255, 0.4);
    background: transparent;
    cursor: pointer;
    position: relative;
    margin: 0;
}
.my-tasks-toggle-done input[type="checkbox"]:checked {
    background: #00E5FF;
    border-color: #00E5FF;
}
.my-tasks-toggle-done input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: -1px;
    width: 4px;
    height: 9px;
    border: solid #010D1A;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.my-tasks-toggle-done:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* Task group sections */
.task-group {
    margin-bottom: 16px;
}
.task-group-header {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 4px;
}
.task-group-header .task-group-count {
    color: rgba(255,255,255,0.25);
    font-weight: 400;
}

/* Task list items */
.task-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
    transition: background 0.1s ease;
}
.task-list-item:hover {
    background: rgba(255,255,255,0.04);
}

.task-list-checkbox {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #94A3B8;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.task-list-checkbox:hover {
    transform: scale(1.2);
    color: #10B981;
}
.task-list-checkbox svg {
    width: 20px;
    height: 20px;
}

.task-list-name {
    flex: 1;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-list-project {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    flex-shrink: 0;
}
.task-list-project-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.task-list-due {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    flex-shrink: 0;
    min-width: 165px;
    text-align: right;
    white-space: nowrap;
}
.task-list-due.overdue {
    color: #EF4444;
}
.task-list-due.today {
    color: #F59E0B;
}

.task-list-priority {
    width: 4px;
    height: 16px;
    flex-shrink: 0;
}

/* Focus styles for keyboard navigation (Clean/Polish phase) */
:focus-visible {
    outline: 2px solid rgba(0, 229, 255, 0.7);
    outline-offset: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* Micro-interactions (Clean/Polish phase) */
button:active:not(:disabled),
.btn:active:not(:disabled),
.header-btn:active:not(:disabled),
.tree-action-btn:active:not(:disabled) {
    transform: scale(0.97);
    transition: transform 0.08s ease;
}
