/* Planning Panel CSS */
/* Part of Terminal Bridge Planning Mode */
/* Created: 2026-01-20 */

/* ============================================
   PLANNING PANEL - RIGHT SIDE COLLAPSIBLE
   ============================================ */

/* Main container wrapping panel + terminal */
.planning-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Terminal container within planning layout */
.planning-layout #terminal-container {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;  /* For floating action buttons */
    /* Allow children to scroll - don't set overflow:hidden here */
}

/* The planning panel itself */
#planning-panel {
    width: var(--planning-panel-width, 280px);
    min-width: 200px;
    max-width: 50vw;
    background: var(--background);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, margin-right 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Collapsed state */
#planning-panel.collapsed {
    width: 0 !important;
    min-width: 0;
    border-left: none;
    margin-right: -1px;
}

#planning-panel.collapsed .planning-panel-content {
    opacity: 0;
    pointer-events: none;
}

/* Panel header — UX-fix3: soft bar matching Documents section (not solid
   Microsoft-blue band). Mark: "blue bar going across agent panel doesn't
   make any sense". */
.planning-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--hover, #f8fafc);
    color: var(--foreground, #1e293b);
    border-bottom: 1px solid var(--border, #e2e8f0);
    flex-shrink: 0;
}

.planning-panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}

/* Mode badge removed in V2 */

.planning-panel-header-actions {
    display: flex;
    gap: 8px;
}

.planning-panel-header-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--foreground, #1e293b);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.15s ease;
}

.planning-panel-header-btn:hover {
    background: rgba(15, 23, 42, 0.06);
}

/* Panel content area */
.planning-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    transition: opacity 0.15s ease;
}

/* Section styling */
.planning-section {
    border-bottom: 1px solid var(--border);
}

.planning-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--hover);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.planning-section-header:hover {
    background: var(--border);
}

.planning-section-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-foreground);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.planning-section-toggle {
    font-size: 10px;
    color: var(--secondary-foreground);
    transition: transform 0.2s ease;
}

.planning-section.collapsed .planning-section-toggle {
    transform: rotate(-90deg);
}

.planning-section-content {
    padding: 12px 16px;
    display: block;
}

.planning-section.collapsed .planning-section-content {
    display: none;
}

/* Project info */
.planning-project-info {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.planning-project-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.planning-project-name i {
    color: var(--button-primary);
}

/* Phase selector removed in V2 */

/* Document list */
.planning-doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.planning-doc-item {
    padding: 10px 12px;
    background: var(--hover);
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.planning-doc-item:last-child {
    margin-bottom: 0;
}

.planning-doc-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--foreground);
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.planning-doc-name i {
    color: var(--success);
    flex-shrink: 0;
    margin-top: 2px;
}

.planning-doc-actions {
    display: flex;
    gap: 6px;
}

.planning-doc-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--secondary-foreground);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.planning-doc-btn:hover {
    background: var(--button-primary);
    color: white;
    border-color: var(--button-primary);
}

/* Action buttons */
.planning-action-btn {
    width: 100%;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--secondary-foreground);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.planning-action-btn:hover {
    border-color: var(--button-primary);
    color: var(--button-primary);
    background: var(--selection-background);
}

.planning-action-btn.primary {
    border-style: solid;
    background: var(--button-primary);
    color: white;
    border-color: var(--button-primary);
}

.planning-action-btn.primary:hover {
    background: var(--button-primary-hover);
}

/* Footer actions */
.planning-panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--hover);
    flex-shrink: 0;
}

/* Resize handle */
.planning-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s ease;
    z-index: 10;
}

.planning-resize-handle:hover,
.planning-resize-handle.dragging {
    background: var(--button-primary);
}

/* Empty states */
.planning-empty-state {
    padding: 20px;
    text-align: center;
    color: var(--secondary-foreground);
    font-size: 12px;
}

.planning-empty-state i {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* No project state */
.planning-no-project {
    padding: 24px 16px;
    text-align: center;
}

.planning-no-project p {
    font-size: 13px;
    color: var(--secondary-foreground);
    margin-bottom: 16px;
}

/* Create project button removed in V2 */

/* Header toggle button (in terminal header) */
#planning-toggle-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--button-primary);
    font-size: 18px;
    transition: all 0.15s ease;
    border-radius: 8px;
}

#planning-toggle-btn:hover {
    background: var(--selection-background);
}

#planning-toggle-btn.active {
    background: var(--button-primary);
    color: white;
}

/* ============================================
   MOBILE STYLES - FULL SCREEN OVERLAY
   ============================================ */

@media (max-width: 768px) {
    #planning-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100%;
        z-index: 2000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-left: none;
    }

    #planning-panel.open {
        transform: translateX(0);
    }

    #planning-panel.collapsed {
        transform: translateX(100%);
        width: 100% !important;
    }

    .planning-resize-handle {
        display: none;
    }

    /* Mobile backdrop */
    #planning-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    #planning-backdrop.visible {
        display: block;
        opacity: 1;
    }

    /* Larger touch targets on mobile */
    .planning-section-header {
        padding: 16px;
    }

    .planning-panel-header {
        padding: 16px;
    }

    .planning-action-btn {
        padding: 14px;
    }

    /* Mobile header buttons - same size as main toolbar (44px) */
    .planning-panel-header-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
        border-radius: 8px;
    }

    .planning-panel-header-actions {
        gap: 8px;
    }
}

/* ============================================
   DESKTOP SPECIFIC
   ============================================ */

@media (min-width: 769px) {
    #planning-backdrop {
        display: none !important;
    }
}

/* ============================================
   TRANSITIONS & ANIMATIONS
   ============================================ */

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

.planning-doc-item {
    animation: slideIn 0.2s ease;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.planning-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--foreground);
    color: var(--background);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 3000;
    pointer-events: none;
}

.planning-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.planning-toast.success {
    background: var(--success);
}

.planning-toast.error {
    background: var(--error);
}

/* ============================================
   PHASE 2: DOCUMENT BROWSER STYLES
   ============================================ */

/* Updated document item with clickable area and menu */
.planning-doc-item {
    padding: 0;
    background: var(--hover);
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: row;  /* Ensure horizontal layout - button on right */
    align-items: stretch;
    gap: 0;
    position: relative;
    overflow: hidden;
}

.planning-doc-info {
    flex: 1;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.15s ease;
}

.planning-doc-info:hover {
    background: var(--border);
}

.planning-doc-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--foreground);
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.planning-doc-name i {
    color: var(--button-primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.planning-doc-meta {
    font-size: 11px;
    color: var(--secondary-foreground);
    display: flex;
    align-items: center;
    gap: 8px;
}

.planning-doc-project-badge {
    background: var(--button-primary);
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.planning-doc-menu-btn {
    width: 36px;
    background: transparent;
    border: none;
    color: var(--secondary-foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.planning-doc-menu-btn:hover {
    background: var(--border);
    color: var(--foreground);
}

/* Context Menu */
.planning-context-menu {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 180px;
    z-index: 100;
    overflow: visible;  /* Allow submenu to extend beyond - fixes clipping bug */
}

.planning-menu-item {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s ease;
}

.planning-menu-item:hover {
    background: var(--hover);
}

.planning-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--secondary-foreground);
}

.planning-menu-item.planning-menu-highlight {
    color: #f59e0b;
}

.planning-menu-item.planning-menu-highlight i {
    color: #f59e0b;
}

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

.planning-menu-item.planning-menu-danger i {
    color: var(--error);
}

.planning-menu-item.disabled {
    color: var(--secondary-foreground);
    cursor: not-allowed;
    opacity: 0.6;
}

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

.planning-menu-label {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary-foreground);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Submenu */
.planning-menu-submenu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.planning-submenu {
    display: none;
    position: absolute !important;
    /* Position BELOW the parent item - more reliable than side positioning */
    left: 0 !important;
    right: auto !important;
    top: 100% !important;  /* Below the parent */
    margin-top: 2px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 150px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 2100;
    padding: 5px 0;  /* Add some padding for easier clicking */
}

/* Scrollable project list in menus */
.planning-project-list-scroll {
    max-height: 250px;
    overflow-y: auto;
}

/* Invisible bridge to maintain hover between parent and submenu */
.planning-menu-submenu::after {
    content: '';
    position: absolute;
    bottom: -10px;  /* Bridge below the item */
    left: 0;
    width: 100%;
    height: 10px;
}

.planning-submenu .planning-menu-item {
    padding: 10px 14px;
    cursor: pointer;  /* Show clickable cursor */
}

.planning-submenu .planning-menu-item:hover {
    background: var(--hover);
}

.planning-submenu .planning-menu-item:active {
    background: var(--active, rgba(59, 130, 246, 0.3));
}

/* Show submenu via JS toggle class (works on all devices) */
.planning-menu-submenu.submenu-open .planning-submenu {
    display: block;
}

/* Only allow hover to open menu on devices that actually support hover (not touch) */
@media (hover: hover) {
    .planning-menu-submenu:hover .planning-submenu {
        display: block;
    }
}

/* Dialog Overlay */
.planning-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.planning-dialog {
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
}

.planning-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--button-primary);
    color: white;
}

.planning-dialog-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.planning-dialog-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.planning-dialog-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.planning-dialog-body {
    padding: 20px;
}

.planning-dialog-info {
    font-size: 13px;
    color: var(--secondary-foreground);
    margin: 0 0 16px 0;
    padding: 10px 12px;
    background: var(--hover);
    border-radius: 6px;
}

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

.planning-form-group:last-child {
    margin-bottom: 0;
}

.planning-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-foreground);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.planning-form-group input,
.planning-form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-background);
    color: var(--foreground);
    transition: border-color 0.15s ease;
}

.planning-form-group input:focus,
.planning-form-group select:focus {
    outline: none;
    border-color: var(--button-primary);
}

.planning-dialog-footer {
    padding: 16px 20px;
    background: var(--hover);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.planning-btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.planning-btn-secondary {
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
}

.planning-btn-secondary:hover {
    background: var(--hover);
}

.planning-btn-primary {
    background: var(--button-primary);
    color: white;
}

.planning-btn-primary:hover {
    background: var(--button-primary-hover);
}

/* Project section styles */
.planning-project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.planning-project-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.planning-project-name i {
    color: var(--button-primary);
}

.planning-project-menu-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--secondary-foreground);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.planning-project-menu-btn:hover {
    background: var(--border);
    color: var(--foreground);
}

.planning-project-phase {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--secondary-foreground);
    margin-bottom: 12px;
}

.planning-project-phase select {
    padding: 4px 8px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-background);
    font-size: 12px;
    color: var(--foreground);
    cursor: pointer;
}

.planning-project-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--secondary-foreground);
    margin-bottom: 8px;
}

.planning-project-stats i {
    margin-right: 4px;
    color: var(--button-primary);
}

.planning-project-primary {
    font-size: 11px;
    color: var(--secondary-foreground);
    padding: 8px;
    background: var(--hover);
    border-radius: 4px;
    margin-top: 8px;
}

.planning-project-primary small {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Project Actions */
.planning-project-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.planning-inject-btn {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.planning-inject-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.planning-inject-btn:active {
    transform: translateY(0);
}

.planning-inject-btn i {
    font-size: 12px;
}

/* Loading state */
.planning-loading {
    padding: 20px;
    text-align: center;
    color: var(--secondary-foreground);
    font-size: 12px;
}

.planning-loading i {
    margin-right: 8px;
}

/* Search Bar */
.planning-search-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--input-background, #2a2a2a);
    border: 1px solid var(--input-border, #444);
    border-radius: 6px;
    margin-bottom: 12px;
    gap: 8px;
}

.planning-search-bar i.fa-search {
    color: var(--secondary-foreground, #888);
    font-size: 12px;
}

.planning-search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--foreground, #fff);
    font-size: 13px;
    padding: 2px 0;
}

.planning-search-bar input::placeholder {
    color: var(--secondary-foreground, #666);
}

.planning-search-clear {
    background: none;
    border: none;
    color: var(--secondary-foreground, #888);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.planning-search-clear:hover {
    background: var(--hover, #333);
    color: var(--foreground, #fff);
}

/* Filter Button */
.planning-filter-btn {
    background: none;
    border: none;
    color: var(--secondary-foreground, #888);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    position: relative;
    transition: all 0.15s ease;
}

.planning-filter-btn:hover {
    background: var(--hover, #333);
    color: var(--foreground, #fff);
}

.planning-filter-btn.active {
    color: var(--accent, #007bff);
}

.planning-filter-btn.active::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 6px;
    width: 6px;
    height: 6px;
    background: var(--accent, #007bff);
    border-radius: 50%;
}

/* Filter Menu Specific Styles */
.planning-filter-menu {
    min-width: 200px;
    max-width: 280px;
}

.planning-filter-menu .planning-menu-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--secondary-foreground, #888);
    border-bottom: 1px solid var(--border, #333);
}

.planning-filter-menu .planning-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.planning-filter-menu .planning-menu-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planning-filter-menu .planning-menu-item.selected {
    background: var(--selection, rgba(0, 123, 255, 0.15));
}

.planning-filter-menu .planning-menu-item i {
    width: 14px;
    text-align: center;
    font-size: 11px;
}

.planning-filter-count {
    font-size: 10px;
    color: var(--secondary-foreground, #666);
    background: var(--hover, #333);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ============================================
   MARKDOWN VIEWER MODAL
   ============================================ */

.markdown-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    padding: 20px;
    box-sizing: border-box;
}

.markdown-viewer-container {
    background: var(--background, #1e1e1e);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.markdown-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0078d4 0%, #106ebe 100%);
    color: white;
    flex-shrink: 0;
}

.markdown-viewer-title {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 12px;
}

.markdown-viewer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.markdown-viewer-menu-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.markdown-viewer-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.markdown-viewer-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    line-height: 1;
    padding-top: 2px; /* Visual centering for × character */
}

.markdown-viewer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.markdown-viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--foreground, #e0e0e0);
    cursor: text;
}

.markdown-viewer-content ::selection {
    background: rgba(0, 120, 212, 0.4);
    color: inherit;
}

/* Markdown Content Styles */
.markdown-viewer-content h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border, #444);
    color: var(--foreground, #fff);
}

.markdown-viewer-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 24px 0 12px 0;
    color: var(--foreground, #fff);
}

.markdown-viewer-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 10px 0;
    color: var(--foreground, #fff);
}

.markdown-viewer-content h4,
.markdown-viewer-content h5,
.markdown-viewer-content h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: var(--secondary-foreground, #aaa);
}

.markdown-viewer-content p {
    margin: 0 0 12px 0;
}

.markdown-viewer-content ul,
.markdown-viewer-content ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.markdown-viewer-content li {
    margin-bottom: 4px;
}

.markdown-viewer-content a {
    color: #58a6ff;
    text-decoration: none;
}

.markdown-viewer-content a:hover {
    text-decoration: underline;
}

.markdown-viewer-content code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-size: 13px;
    background: var(--hover, #2a2a2a);
    padding: 2px 6px;
    border-radius: 4px;
}

.markdown-viewer-content pre {
    background: var(--hover, #2a2a2a);
    border: 1px solid var(--border, #444);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 0 0 16px 0;
}

.markdown-viewer-content pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.markdown-viewer-content blockquote {
    margin: 0 0 16px 0;
    padding: 12px 16px;
    border-left: 4px solid var(--button-primary, #0078d4);
    background: var(--hover, #2a2a2a);
    border-radius: 0 8px 8px 0;
}

.markdown-viewer-content blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-viewer-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px 0;
    font-size: 13px;
}

.markdown-viewer-content th,
.markdown-viewer-content td {
    padding: 10px 12px;
    text-align: left;
    border: 1px solid var(--border, #444);
}

.markdown-viewer-content th {
    background: var(--hover, #2a2a2a);
    font-weight: 600;
    color: var(--foreground, #fff);
}

.markdown-viewer-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.markdown-viewer-content hr {
    border: none;
    border-top: 1px solid var(--border, #444);
    margin: 24px 0;
}

.markdown-viewer-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Loading state in viewer */
.markdown-viewer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--secondary-foreground, #888);
}

.markdown-viewer-loading i {
    margin-right: 10px;
}

/* KB Sources section removed in V2 */

/* ============================================
   MORNING BRIEF SECTION (V2)
   ============================================ */

.brief-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 10px;
}

.brief-section {
    margin-bottom: 10px;
}

.brief-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary-foreground);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brief-section-title i {
    font-size: 10px;
}

.brief-event {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.brief-event-time {
    color: var(--button-primary);
    font-weight: 600;
    min-width: 50px;
    font-size: 11px;
}

.brief-event-title {
    color: var(--foreground);
    flex: 1;
}

.brief-tasks {
    padding: 8px 10px;
    background: var(--hover);
    border-radius: 6px;
    font-size: 12px;
    color: var(--secondary-foreground);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brief-tasks strong {
    color: var(--button-primary);
}

.brief-report {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.brief-report:last-child {
    border-bottom: none;
}

.brief-report-source {
    font-size: 11px;
    font-weight: 600;
    color: var(--foreground);
    text-transform: capitalize;
}

.brief-report-preview {
    font-size: 11px;
    color: var(--secondary-foreground);
    margin-top: 2px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.brief-empty {
    font-size: 12px;
    color: var(--secondary-foreground);
    text-align: center;
    padding: 8px;
}

/* ============================================
   PROMPT SEND BUTTON IN VIEWER (V2 Phase 4)
   ============================================ */

.viewer-send-prompt-btn {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease;
}

.viewer-send-prompt-btn:hover {
    background: #059669;
}

.viewer-send-prompt-btn i {
    font-size: 11px;
}

.markdown-viewer-search {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    color: white;
    font-size: 13px;
    padding: 6px 10px;
    width: 200px;
    outline: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.markdown-viewer-search::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.markdown-viewer-search:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

mark.viewer-search-hit {
    background: #fde047;
    color: #111;
    padding: 0 1px;
    border-radius: 2px;
}

/* ============================================
   TASKS SECTION (V2)
   ============================================ */

.planning-task-count {
    font-size: 11px;
    color: var(--button-primary);
    font-weight: 600;
    margin-left: 4px;
}

/* Project search results */
.planning-project-result {
    cursor: pointer;
}

.planning-project-result .planning-doc-info {
    cursor: pointer;
}

.planning-project-result.project-result-active {
    opacity: 0.6;
}

/* Task section header actions */
.planning-section-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-menu-wrapper {
    position: relative;
}

.task-menu-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--secondary-foreground);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.task-menu-btn:hover {
    background: var(--border);
    color: var(--foreground);
}

.task-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 140px;
    padding: 4px;
}

.task-menu-dropdown.show {
    display: block;
}

.task-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--foreground);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
}

.task-menu-dropdown button:hover {
    background: var(--hover);
}

.task-menu-dropdown button i {
    color: var(--secondary-foreground);
    width: 14px;
    text-align: center;
}

/* Task item */
.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    background: var(--hover);
    border-left: 3px solid transparent;
    transition: background 0.15s ease;
}

.task-item:hover {
    background: var(--border);
}

.task-item:last-child {
    margin-bottom: 0;
}

/* Priority borders */
.task-item.task-priority-high {
    border-left-color: var(--error);
}

.task-item.task-priority-low {
    opacity: 0.7;
}

/* Done state */
.task-item.task-done {
    opacity: 0.5;
}

.task-item.task-done .task-title {
    text-decoration: line-through;
}

/* Blocked state */
.task-item.task-blocked {
    border-left-color: #f59e0b;
}

/* Checkbox area */
.task-checkbox {
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.task-check {
    color: var(--secondary-foreground);
    transition: color 0.15s ease;
}

.task-check.done {
    color: var(--success);
}

.task-check.blocked {
    color: #f59e0b;
}

.task-checkbox:hover .task-check {
    color: var(--success);
}

/* Task content */
.task-content {
    flex: 1;
    min-width: 0;
}

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

.task-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--foreground);
    word-break: break-word;
}

/* Type icons */
.task-icon-bug {
    color: var(--error);
    font-size: 11px;
    flex-shrink: 0;
}

.task-icon-feature {
    color: #3b82f6;
    font-size: 11px;
    flex-shrink: 0;
}

.task-icon-task {
    color: var(--secondary-foreground);
    font-size: 11px;
    flex-shrink: 0;
}

.task-icon-admin {
    color: #f59e0b;
    font-size: 11px;
    flex-shrink: 0;
}

/* Task notes */
.task-notes {
    font-size: 11px;
    color: var(--secondary-foreground);
    margin-top: 4px;
    line-height: 1.4;
}

/* Task meta line */
.task-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.task-owner {
    font-size: 10px;
    color: var(--secondary-foreground);
    background: var(--background);
    padding: 1px 6px;
    border-radius: 3px;
}

.task-age {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-left: 5px;
    padding: 0 3px;
    border-radius: 2px;
    background: rgba(156, 163, 175, 0.12);
}

.task-status-label {
    font-size: 10px;
    color: #f59e0b;
    font-weight: 600;
}

/* List groups (V2.1) */
.list-group {
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.list-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--secondary-background, rgba(255,255,255,0.03));
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
}

.list-group-header:hover {
    background: var(--hover-background, rgba(255,255,255,0.06));
}

.list-group-name {
    flex: 1;
}

.list-group-count {
    background: var(--button-primary, #4a9eff);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.list-group-count:empty {
    display: none;
}

.list-group-toggle {
    font-size: 10px;
    transition: transform 0.2s ease;
    color: var(--secondary-foreground);
}

.list-collapsed .list-group-items {
    display: none;
}

.list-collapsed .list-group-toggle {
    transform: rotate(-90deg);
}

.list-group-items {
    padding: 0 4px 4px;
}

.list-empty {
    font-size: 12px;
    color: var(--secondary-foreground);
    text-align: center;
    padding: 8px;
}

/* List type icon colors */
.list-icon-trades { color: #f59e0b; }
.list-icon-jobs { color: #3b82f6; }
.list-icon-snagging { color: #ef4444; }
.list-icon-shopping { color: #10b981; }
.list-icon-health { color: #ec4899; }
.list-icon-admin { color: #8b5cf6; }
.list-icon-project { color: #6366f1; }
.list-icon-custom { color: #9ca3af; }

/* Item badges */
.item-urgent {
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-area {
    font-size: 10px;
    color: var(--secondary-foreground);
    background: rgba(255,255,255,0.05);
    padding: 1px 5px;
    border-radius: 3px;
}

/* Done group */
.task-done-group {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.task-done-header {
    font-size: 11px;
    color: var(--secondary-foreground);
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.task-done-header i {
    font-size: 9px;
    transition: transform 0.2s ease;
    margin-right: 4px;
}

.task-done-list.collapsed {
    display: none;
}

.task-done-list.collapsed + .task-done-header i,
.task-done-group:has(.task-done-list.collapsed) .task-done-header i {
    transform: rotate(-90deg);
}

/* Inline editing state */
.task-title-editing {
    background: var(--input-background, #1e1e2e);
    border: 1px solid var(--button-primary);
    border-radius: 4px;
    padding: 4px 6px;
    outline: none;
    min-width: 100px;
    cursor: text;
}

/* Mobile: larger tap targets for task checkboxes */
@media (max-width: 768px) {
    .task-checkbox {
        padding: 6px;
        font-size: 20px;
    }

    .task-item {
        padding: 12px;
    }

    .task-title-editing {
        font-size: 16px;  /* Prevent iOS zoom on focus */
    }
}

/* Mobile adjustments for viewer */
@media (max-width: 768px) {
    .markdown-viewer-overlay {
        padding: 0;
    }

    .markdown-viewer-container {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .markdown-viewer-content {
        padding: 16px;
    }
}

/* ===== V2.2 — cross-project lists + project description ===== */

.planning-project-description {
    font-size: 12px;
    color: var(--secondary-foreground);
    line-height: 1.4;
    margin: 4px 0 8px 0;
    padding: 0 2px;
}

/* Per-task 3-dot menu button — mirrors the documents pattern */
.task-item-menu-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--secondary-foreground);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
    opacity: 0.5;
}

.task-item:hover .task-item-menu-btn {
    opacity: 1;
}

.task-item-menu-btn:hover {
    background: var(--border);
    color: var(--foreground);
}

/* Give the list-group-name room to ellipsis when it holds "Project · List" */
.list-group-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Clickable Active Project block — one-click filter both searches to current */
.planning-active-project-clickable {
    cursor: pointer;
    padding: 6px;
    margin: -6px;
    border-radius: 6px;
    transition: background 0.15s ease;
}
.planning-active-project-clickable:hover {
    background: var(--hover, rgba(255,255,255,0.04));
}

/* Project badge on document rows — now a click-to-switch shortcut */
.planning-doc-project-badge-clickable {
    cursor: pointer;
    transition: filter 0.12s ease, box-shadow 0.12s ease;
}
.planning-doc-project-badge-clickable:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 0 1px var(--accent, #4a9eff);
}

/* Lists section search bar — tighten spacing inside the section content */
.planning-lists-search-bar {
    margin: 4px 0 8px 0;
}

.planning-lists-results {
    /* Nothing specific — placeholder so we can target later if needed */
}

/* ============================================================
   AGENTS ROSTER (P0 — replaces Active Project)
   Live roster of dispatched AV agents grouped by attention state.
   (T7/agy dropped from the roster — dormant, Mark 2026-06-11.)
   Reuses the pip dot colours from terminal_bridge.html.
   Rendered by PlanningPanel.renderRoster().
   ============================================================ */

/* Relocated project actions in the Documents & Projects section header —
   styled like the Lists menu button (transparent, secondary on the light
   section header), distinct from the white header buttons. */
.planning-doc-action-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--secondary-foreground);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}
.planning-doc-action-btn:hover {
    background: var(--border);
    color: var(--foreground);
}

/* Tally line: "1 needs you · 4 working · 2 done" */
.agents-tally {
    font-size: 12px;
    color: var(--secondary-foreground);
    padding: 2px 2px 10px 2px;
    letter-spacing: 0.2px;
}
.agents-tally .agents-tally-need { color: #f59e0b; font-weight: 600; }
.agents-tally .agents-tally-work { color: #22c55e; font-weight: 600; }
.agents-tally .agents-tally-done { color: #f59e0b; }
.agents-tally .agents-tally-sep { color: var(--border); margin: 0 4px; }

/* Group heading within the roster */
.agents-group {
    margin-bottom: 10px;
}
.agents-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--secondary-foreground);
    margin: 6px 2px 4px 2px;
}
.agents-group-idle { opacity: 0.7; }

/* Collapsible Done / Idle piles — tap the heading to fold the old rows away
   (mirrors the task-list .list-group-header toggle). Rows stay in the DOM;
   only the .agents-group-items box is hidden, so nothing is lost. */
.agents-group-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.agents-group-toggle .agents-group-label { flex-shrink: 0; }
.agents-group-toggle .agents-group-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--secondary-foreground);
    opacity: 0.75;
}
.agents-group-chevron {
    font-size: 9px;
    margin-left: auto;
    color: var(--secondary-foreground);
    transition: transform 0.2s ease;
}
.agents-group-collapsed .agents-group-items { display: none; }
.agents-group-collapsed .agents-group-chevron { transform: rotate(-90deg); }

/* A roster row */
.agents-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--hover);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease;
}
.agents-row:hover { background: var(--border); }
.agents-row:active { transform: scale(0.99); }
.agents-row.agents-row-self {
    box-shadow: inset 0 0 0 1px var(--button-primary);
}
.agents-row.agents-row-idle { opacity: 0.65; }

/* State dot — colours mirror the top-bar pip dots */
.agents-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset;
}
.agents-row[data-state="running"] .agents-dot { background: #22c55e; }
.agents-row[data-state="waiting"] .agents-dot {
    background: #f59e0b;
    animation: agents-dot-pulse 1.2s ease-in-out infinite;
}
/* Done/unread = calm SOLID blue (no orange pulse). The orange flash is reserved
   for genuine "needs you" (waiting) + the pips' attention signal — reusing it for
   "done" was confusing (Mark 2026-06-18). */
.agents-row[data-state="unread"] .agents-dot { background: #60a5fa; }
.agents-row[data-state="idle"] .agents-dot { background: #6b7280; }
.agents-row[data-goal-mode="true"] .agents-dot { background: #a855f7; }
@keyframes agents-dot-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.7); }
    50%     { box-shadow: 0 0 0 4px rgba(245,158,11,0); }
}

/* Title + badges column (flexes to fill, truncates) */
.agents-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.agents-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agents-row-idle .agents-title { color: var(--secondary-foreground); }

/* Small slot badge (T3) */
.agents-slot-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--secondary-foreground);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    flex-shrink: 0;
}

/* Purple goal badge */
.agents-goal-badge {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #a855f7;
    border-radius: 4px;
    padding: 1px 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* "tap to read" hint on Done rows */
.agents-hint {
    font-size: 10px;
    color: #f59e0b;
    flex-shrink: 0;
}

/* Elapsed time, right-aligned */
.agents-elapsed {
    font-size: 11px;
    color: var(--secondary-foreground);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Stacked row: title line on top, owner·model meta-line below */
.agents-main-stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.agents-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}
.agents-meta {
    font-size: 10px;
    color: var(--secondary-foreground);
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
/* Loop #229: live "what it's doing right now" line on a working row */
.agents-substep {
    font-size: 10.5px;
    color: var(--secondary-foreground);
    font-style: italic;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ============================================================
   AV transcript reader (read-only) — overlays the roster within
   the panel; its own scroll, back button to the list. The roster
   render stands down while this is open (state.readerOpen).
   ============================================================ */
#agents-reader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    flex-direction: column;
    z-index: 5;
}
.reader-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.reader-back {
    background: var(--hover);
    border: 1px solid var(--border);
    color: var(--foreground);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}
.reader-back:hover { background: var(--border); }
.reader-title {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reader-t8 {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--secondary-foreground);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}
.reader-t8:hover { background: var(--hover); color: var(--foreground); }
.reader-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}
.reader-error {
    color: #f59e0b;
    font-size: 12px;
    padding: 16px 8px;
    text-align: center;
}
/* Loop #234: session is a live interactive terminal — offer the jump */
.reader-live-banner {
    background: rgba(59, 130, 246, 0.12);
    border-bottom: 1px solid rgba(59, 130, 246, 0.35);
    color: var(--foreground, #ddd);
    font-size: 12px;
    padding: 8px 10px;
    text-align: center;
}
.reader-live-switch {
    background: #3b82f6;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
    padding: 3px 10px;
}
.reader-live-switch:hover { background: #2563eb; }

/* One turn */
.reader-turn {
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 12.5px;
    line-height: 1.45;
}
.reader-role {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
    color: var(--secondary-foreground);
}
.reader-text {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;   /* iOS Safari: break very long unbroken tokens
                                  (paths/urls/base64) so nothing forces a sideways pan */
    color: var(--foreground);
    max-width: 100%;
}
.reader-user .reader-role { color: #60a5fa; }
.reader-user {
    background: var(--hover);
    padding: 7px 9px;
}
.reader-assistant .reader-role { color: #22c55e; }
.reader-assistant { padding: 2px 2px; }
.reader-tts .reader-text {
    border-left: 2px solid #a855f7;
    padding-left: 8px;
    color: var(--secondary-foreground);
    font-style: italic;
}

/* --- Agents reader v2 (Mark 2026-06-18): TB-style blue/orange + selectable --- */
/* Double-click a block to select it for read-aloud (the green speaker). */
.reader-selectable { -webkit-user-select: text; user-select: text; cursor: text; }
/* Every user turn now renders its own blue prompt box, so drop the row's grey
   backing to avoid a box-in-box. */
.reader-user { background: none; padding: 2px 2px; }
/* Orange ⟦TTS⟧ box (reuses .tts-narrow-block from terminal-bridge.css) spacing. */
.reader-tts-box { margin: 10px 0; }
.reader-tts-box .tts-body {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    margin-top: 4px;
}
/* Per-row delete ✕ — subtle until hover, red on hover (the Ctrl+X-Ctrl+X equiv). */
.agents-del {
    flex: 0 0 auto;
    margin-left: 6px;
    background: none;
    border: none;
    color: var(--secondary-foreground, #94a3b8);
    opacity: 0.35;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.agents-row:hover .agents-del { opacity: 0.7; }
.agents-del:hover { opacity: 1; color: #ef4444; background: rgba(239, 68, 68, 0.12); }
/* 🔊 read-aloud on a reader block — top-right corner, self-contained tap target. */
.reader-speak {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.65;
}
.reader-speak:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }

/* Collapsed tool one-liner */
.reader-tool {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--mono-font, monospace);
    font-size: 11px;
    margin-bottom: 4px;
    padding: 2px 4px;
    opacity: 0.92;
}
.reader-tool-mark { flex-shrink: 0; font-weight: 700; }
.tool-ok .reader-tool-mark { color: #22c55e; }
.tool-err .reader-tool-mark { color: #ef4444; }
.reader-tool-name {
    color: var(--foreground);
    font-weight: 600;
    flex-shrink: 0;
}
.reader-tool-summary {
    color: var(--secondary-foreground);
    /* Wrap full commands / file paths like a real terminal, instead of clipping
       them to one ellipsised line — this was the visible "won't wrap" fault on
       a phone (the prose already wrapped; the tool lines did not). */
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}
.reader-more {
    display: block;
    width: 100%;
    background: var(--hover);
    border: 1px solid var(--border);
    color: var(--foreground);
    border-radius: 6px;
    padding: 8px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 6px;
}
.reader-more:hover { background: var(--border); }

/* ---- Phone: no zoom-on-focus (loop: TB phone-usability bundle, 2026-08-16) ----
   DEVIATION NOTE: item 6 named only the generic `input` rule in terminal-bridge.css
   (raised to 16px there). Measured on the live page, that rule does not reach the
   box the item exists to fix: .markdown-viewer-search IS the doc-viewer find box,
   and it plus the planning search inputs carry their own more-specific 13px rules,
   so all three still zoomed. Scoped to the phone query — under 16px iOS zooms the
   page on focus and never zooms back — so desktop keeps its 13px look. */
@media (max-width: 600px) {
    .markdown-viewer-search,
    .planning-search-bar input {
        font-size: 16px;
    }
}
