/* ============================================================
   Ecosystem Visualization Tab
   ============================================================ */

.ecosystem-section.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* -- Toolbar ------------------------------------------------- */
.ecosystem-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.ecosystem-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* -- Controls ------------------------------------------------ */
.ecosystem-controls {
    display: flex;
    gap: 6px;
}

.eco-ctrl-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
    padding: 0;
}

.eco-ctrl-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent-blue, #4dabf7);
}

.eco-ctrl-btn.eco-ctrl-reset {
    width: auto;
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* -- Legend --------------------------------------------------- */
.ecosystem-legend {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-left: auto;
    flex-wrap: wrap;
}

.eco-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.eco-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.eco-legend-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* -- Canvas Wrap --------------------------------------------- */
.ecosystem-canvas-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    cursor: grab;
    background:
        radial-gradient(circle, var(--border-light) 1px, transparent 1px);
    background-size: 30px 30px;
    background-position: 0 0;
}

.ecosystem-canvas-wrap.grabbing {
    cursor: grabbing;
}

/* -- Canvas -------------------------------------------------- */
.ecosystem-canvas {
    width: 4200px;
    height: 2800px;
    position: relative;
    transform-origin: 0 0;
}

/* -- SVG Layer ----------------------------------------------- */
.eco-svg-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.eco-svg-layer path {
    stroke: var(--border-light);
    stroke-width: 2;
    fill: none;
    opacity: 0.4;
    transition: opacity 0.2s, stroke-width 0.2s;
}

.eco-svg-layer path.eco-path-highlight {
    opacity: 1;
    stroke-width: 3;
    stroke: var(--accent-blue, #4dabf7);
}

/* Hovered node and connected nodes */
.eco-node.eco-node-hover-connected {
    transform: scale(1.05);
}

/* -- Nodes Layer --------------------------------------------- */
.eco-nodes-layer {
    position: relative;
    width: 100%;
    height: 100%;
}

.eco-node {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 140px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s, box-shadow 0.15s;
    border-left: 4px solid;
    user-select: none;
}

.eco-node:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

.eco-node.eco-node-dragging {
    cursor: grabbing;
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 100;
    transition: none;
}

.eco-node {
    cursor: grab;
}

.eco-node-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.eco-node-category {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.eco-node-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 8px;
    right: 8px;
    background: #51cf66;
}

/* -- Tooltip ------------------------------------------------- */
.ecosystem-tooltip {
    position: fixed;
    z-index: 1000;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
    max-width: 280px;
    pointer-events: none;
}

.eco-tooltip-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.eco-tooltip-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.eco-tooltip-connections {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* -- Selected Node ------------------------------------------- */
.eco-node.eco-node-selected {
    border-color: var(--accent-blue, #4dabf7);
    box-shadow: 0 0 0 2px var(--accent-blue, #4dabf7), 0 4px 16px rgba(0,0,0,0.12);
    z-index: 20;
}

/* -- Connected Nodes (raised when a node is selected) -------- */
.eco-node.eco-node-connected {
    transform: scale(1.04);
    z-index: 15;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
    border-color: rgba(77, 171, 247, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* -- Detail Panel (slide from right) ------------------------- */
.eco-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 360px;
    height: 100%;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-light);
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.eco-detail-panel.open {
    transform: translateX(0);
}

.eco-detail-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.eco-detail-color-bar {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    margin-bottom: 12px;
}

.eco-detail-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.eco-detail-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
}

.eco-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 20px;
}

.eco-detail-section {
    margin-bottom: 18px;
}

.eco-detail-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.eco-detail-desc {
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.eco-detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.eco-detail-list li {
    font-size: 0.78rem;
    color: var(--text-primary);
    padding: 5px 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.eco-detail-list li:last-child {
    border-bottom: none;
}

.eco-detail-list-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.eco-detail-files {
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.eco-detail-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.eco-detail-stat:last-child { border-bottom: none; }

.eco-detail-stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.eco-detail-stat-value {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* -- Header Row (badge + admin toggle) ------------------------------ */
.eco-detail-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* -- Admin Toggle Button -------------------------------------------- */
.eco-admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}

.eco-admin-toggle:hover {
    background: var(--bg-surface);
    border-color: var(--accent-blue, #4dabf7);
    color: var(--accent-blue, #4dabf7);
}

.eco-admin-toggle.active {
    background: var(--accent-blue, #4dabf7);
    border-color: var(--accent-blue, #4dabf7);
    color: #fff;
}

.eco-admin-toggle svg {
    flex-shrink: 0;
}

/* -- Admin Section -------------------------------------------------- */
.eco-admin-section {
    border-top: 1px dashed var(--border-light);
    margin-top: 12px;
    padding-top: 12px;
}

/* -- Canvas Transition (sub-view zoom) ------------------------------ */
.eco-canvas-transitioning {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -- Sub-view Back Button ------------------------------------------- */
.eco-back-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.eco-back-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent-blue, #4dabf7);
    transform: translateX(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.eco-back-btn:active {
    transform: translateX(-1px) scale(0.97);
}

.eco-back-btn.visible {
    display: flex;
}

/* -- Sub-view Center Card ------------------------------------------- */
.eco-sub-center {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 20px 24px;
    min-width: 220px;
    max-width: 280px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14), 0 0 40px rgba(77, 171, 247, 0.08);
    border-left: 6px solid;
    user-select: none;
    z-index: 5;
    opacity: 0;
    transform: scale(0.85);
    animation: ecoSubCenterIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* -- Sub-view Surrounding Cards ------------------------------------- */
.eco-sub-card {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 180px;
    max-width: 220px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    border-left: 4px solid;
    user-select: none;
    z-index: 5;
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    animation: ecoSubCardIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: var(--card-delay, 0.06s);
}

/* List variant gets more room */
.eco-sub-card.eco-sub-card-list {
    min-width: 200px;
    max-width: 280px;
}

/* -- Sub-view List Styling ------------------------------------------ */
.eco-sub-list {
    margin: 6px 0 0 0;
    padding-left: 16px;
    list-style: disc;
    max-height: 180px;
    overflow-y: auto;
}

.eco-sub-list li {
    margin-bottom: 3px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.eco-sub-list::-webkit-scrollbar {
    width: 4px;
}

.eco-sub-list::-webkit-scrollbar-track {
    background: transparent;
}

.eco-sub-list::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* -- Sub-view Text -------------------------------------------------- */
.eco-sub-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.eco-sub-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.eco-sub-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 5px;
    margin-bottom: 6px;
}

/* -- Sub-view SVG Lines --------------------------------------------- */
.eco-svg-layer path.eco-sub-line {
    stroke-width: 2;
    opacity: 0.3;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: ecoSubLineIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: var(--line-delay, 0.1s);
}

/* -- Sub-view Entrance Animations ----------------------------------- */
@keyframes ecoSubCenterIn {
    to { opacity: 1; transform: scale(1); }
}

@keyframes ecoSubCardIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ecoSubLineIn {
    to { stroke-dashoffset: 0; }
}

/* -- Reduced Motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .eco-canvas-transitioning {
        transition: opacity 0.1s linear;
    }
    .eco-sub-center {
        animation: none;
        opacity: 1;
        transform: scale(1);
    }
    .eco-sub-card {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .eco-svg-layer path.eco-sub-line {
        animation: none;
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }
    .eco-back-btn {
        transition: none;
    }
}

/* ==========================================
   ECOSYSTEM ENGINE — INSTANCE B STYLES
   ========================================== */

/* --- B1: Knowledge Graph --- */
.graph-overlay { position: fixed; inset: 0; background: var(--bg-primary); z-index: 1000; display: flex; flex-direction: column; }
.graph-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary); }
.graph-close-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 6px; transition: background 0.15s; }
.graph-close-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.graph-filter-bar { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.graph-filter-chip { padding: 4px 10px; border-radius: 12px; font-size: 12px; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-tertiary); color: var(--text-secondary); transition: all 0.15s; }
.graph-filter-chip.active { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
.graph-filter-chip:hover { background: var(--bg-secondary); }
.graph-canvas-container { flex: 1; overflow: hidden; position: relative; }
.graph-canvas-container svg { width: 100%; height: 100%; }
.graph-node { cursor: pointer; transition: opacity 0.2s; }
.graph-node circle { transition: r 0.2s, stroke-width 0.2s; }
.graph-node:hover circle { stroke-width: 3; }
.graph-node--selected circle { stroke: var(--accent-color); stroke-width: 3; }
.graph-node--dimmed { opacity: 0.2; }
.graph-node-label { font-size: 11px; fill: var(--text-secondary); pointer-events: none; }
.graph-edge-line { stroke: var(--border-color); stroke-width: 1.5; opacity: 0.5; transition: opacity 0.2s, stroke 0.2s; }
.graph-edge-line--highlighted { stroke: var(--accent-color); opacity: 1; stroke-width: 2; }
.graph-tooltip { position: absolute; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: none; z-index: 10; max-width: 250px; font-size: 13px; }
.graph-tooltip-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.graph-tooltip-meta { font-size: 11px; color: var(--text-muted); }
.graph-stats-bar { padding: 8px 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border-color); display: flex; gap: 16px; background: var(--bg-secondary); }

/* --- B1: Context Panel --- */
.context-panel { border-top: 1px solid var(--border-color); padding: 12px 0; margin-top: 12px; }
.context-section { margin-bottom: 12px; }
.context-section-header { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; cursor: pointer; user-select: none; }
.context-section-header:hover { color: var(--text-secondary); }
.context-section-toggle { transition: transform 0.2s; display: inline-block; }
.context-section-toggle.collapsed { transform: rotate(-90deg); }
.context-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
.context-item:hover { background: var(--bg-tertiary); }
.context-item-icon { font-size: 14px; color: var(--text-muted); width: 16px; text-align: center; }
.context-item-title { font-size: 13px; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-item-badge { font-size: 11px; color: var(--text-muted); padding: 2px 6px; background: var(--bg-tertiary); border-radius: 4px; }
.context-empty { font-size: 12px; color: var(--text-muted); padding: 8px; font-style: italic; }

/* --- B1: Backlink Badge --- */
.backlink-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-muted); padding: 2px 6px; background: var(--bg-tertiary); border-radius: 4px; margin-left: 6px; }

/* --- B3: Notification Bell --- */
.eco-notif-bell { position: relative; cursor: pointer; padding: 6px; border-radius: 6px; transition: background 0.15s; background: none; border: none; color: var(--text-secondary); }
.eco-notif-bell:hover { background: var(--bg-tertiary); }
.eco-notif-bell-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; border-radius: 8px; background: #ff6b6b; color: #fff; font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.eco-notif-bell-badge:empty { display: none; }

/* --- B3: Notification Panel --- */
.eco-notif-panel { position: fixed; top: 0; right: -380px; width: 380px; height: 100vh; background: var(--bg-secondary); border-left: 1px solid var(--border-color); box-shadow: -4px 0 16px rgba(0,0,0,0.1); z-index: 900; transition: right 0.25s ease; display: flex; flex-direction: column; }
.eco-notif-panel--open { right: 0; }
.eco-notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.eco-notif-panel-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.eco-notif-panel-list { flex: 1; overflow-y: auto; padding: 8px; }
.eco-notif-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.eco-notif-item:hover { background: var(--bg-tertiary); }
.eco-notif-item--unread { background: rgba(77,171,247,0.06); }
.eco-notif-item-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); flex-shrink: 0; }
.eco-notif-item-body { flex: 1; min-width: 0; }
.eco-notif-item-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.eco-notif-item-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-notif-item-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.eco-notif-item-dismiss { opacity: 0; transition: opacity 0.15s; cursor: pointer; color: var(--text-muted); background: none; border: none; padding: 4px; }
.eco-notif-item:hover .eco-notif-item-dismiss { opacity: 1; }
.eco-notif-mark-all { font-size: 12px; color: var(--accent-color); cursor: pointer; padding: 4px 8px; border-radius: 4px; background: none; border: none; }
.eco-notif-mark-all:hover { background: var(--bg-tertiary); }
.eco-notif-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }

/* --- B3: Recommendations --- */
.rec-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 10px; padding: 16px; }
.rec-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.rec-item:last-child { border-bottom: none; }
.rec-item-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--bg-tertiary); }
.rec-item-body { flex: 1; }
.rec-item-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.rec-item-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.rec-item-action { font-size: 12px; color: var(--accent-color); cursor: pointer; padding: 4px 10px; border-radius: 4px; border: 1px solid var(--accent-color); background: transparent; transition: all 0.15s; white-space: nowrap; }
.rec-item-action:hover { background: var(--accent-color); color: #fff; }

/* --- B3: Promotions --- */
.promo-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-tertiary); border-radius: 6px; margin-bottom: 6px; }
.promo-arrow { color: var(--text-muted); }
.promo-accept { font-size: 12px; color: var(--accent-color); cursor: pointer; background: none; border: none; padding: 4px 8px; }
.promo-accept:hover { text-decoration: underline; }
.promo-dismiss { font-size: 12px; color: var(--text-muted); cursor: pointer; background: none; border: none; padding: 4px; }

/* --- B4: Tag Tree --- */
.tag-tree { padding: 4px 0; }
.tag-tree-node { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; transition: background 0.15s; }
.tag-tree-node:hover { background: var(--bg-tertiary); }
.tag-tree-children { padding-left: 16px; }
.tag-tree-toggle { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; }
.tag-tree-toggle.collapsed { transform: rotate(-90deg); }
.tag-tree-color-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-tree-name { color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-tree-count { font-size: 11px; color: var(--text-muted); padding: 1px 5px; background: var(--bg-tertiary); border-radius: 4px; }

/* --- B4: Collections --- */
.collection-sidebar-section { padding: 8px 0; border-top: 1px solid var(--border-color); }
.collection-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-secondary); font-size: 12px; cursor: pointer; transition: all 0.15s; margin: 2px; }
.collection-chip.active { border-color: var(--accent-color); color: var(--accent-color); font-weight: 600; }
.collection-chip:hover { background: var(--bg-tertiary); }
.collection-add-btn { border-style: dashed; color: var(--text-muted); }
.collection-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); z-index: 1000; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; }
.collection-item-card { padding: 8px; border-radius: 6px; background: var(--bg-tertiary); cursor: pointer; transition: background 0.15s; }
.collection-item-card:hover { background: var(--bg-secondary); }
.collection-empty { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* --- B4: Semantic Clusters --- */
.cluster-panel { padding: 16px; }
.cluster-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.cluster-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cluster-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.cluster-reason { font-size: 11px; color: var(--text-muted); padding: 2px 8px; background: var(--bg-tertiary); border-radius: 4px; }
.cluster-items { display: flex; flex-wrap: wrap; gap: 6px; }
.cluster-create-btn { margin-top: 8px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--accent-color); background: transparent; color: var(--accent-color); font-size: 12px; cursor: pointer; transition: all 0.15s; }
.cluster-create-btn:hover { background: var(--accent-color); color: #fff; }

/* --- B5: Timeline --- */
.timeline-view { padding: 16px 20px; max-height: 80vh; overflow-y: auto; }
.timeline-filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.timeline-type-chip { padding: 3px 8px; border-radius: 10px; font-size: 11px; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-tertiary); color: var(--text-secondary); transition: all 0.15s; }
.timeline-type-chip.active { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
.timeline-date-group { margin-bottom: 20px; }
.timeline-date-header { font-size: 13px; font-weight: 600; color: var(--text-primary); padding: 6px 0; border-bottom: 2px solid var(--accent-color); margin-bottom: 8px; }
.timeline-line { position: relative; padding-left: 24px; border-left: 2px solid var(--border-color); margin-left: 8px; }
.timeline-connector { position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; }
.timeline-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 4px; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
.timeline-item:hover { background: var(--bg-tertiary); }
.timeline-item-time { font-size: 11px; color: var(--text-muted); min-width: 50px; }
.timeline-item-title { font-size: 13px; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- B5: Correlations --- */
.correlation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.correlation-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 10px; padding: 16px; }
.correlation-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.correlation-card-chart { margin: 8px 0; }
.correlation-insight-text { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* --- B5: Replay --- */
.replay-overlay { position: fixed; inset: 0; background: var(--bg-primary); z-index: 1000; display: flex; flex-direction: column; }
.replay-header { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary); }
.replay-controls { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); }
.replay-play-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--accent-color); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: filter 0.15s; }
.replay-play-btn:hover { filter: brightness(1.1); }
.replay-speed-btn { padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-tertiary); color: var(--text-secondary); font-size: 12px; cursor: pointer; transition: all 0.15s; }
.replay-speed-btn.active { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
.replay-slider-track { flex: 1; height: 8px; background: var(--bg-tertiary); border-radius: 4px; position: relative; cursor: pointer; }
.replay-slider-fill { height: 100%; background: var(--accent-color); border-radius: 4px; transition: width 0.1s; }
.replay-slider-thumb { position: absolute; top: -4px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent-color); border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2); cursor: grab; }
.replay-timestamp { font-size: 14px; font-weight: 600; color: var(--text-primary); min-width: 60px; font-family: 'JetBrains Mono', monospace; }
.replay-event-list { flex: 1; overflow-y: auto; padding: 12px 20px; }
.replay-event-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; margin-bottom: 4px; background: var(--bg-secondary); font-size: 13px; }
.replay-event-item-time { font-size: 11px; color: var(--text-muted); min-width: 50px; }

/* --- B6: Automation --- */
.auto-panel { padding: 16px; }
.auto-rule { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 8px; background: var(--bg-secondary); }
.auto-rule-trigger { font-size: 12px; padding: 3px 8px; border-radius: 4px; background: var(--bg-tertiary); color: var(--text-primary); }
.auto-rule-arrow { color: var(--text-muted); font-size: 14px; }
.auto-rule-action { font-size: 12px; padding: 3px 8px; border-radius: 4px; background: rgba(77,171,247,0.1); color: var(--accent-color); }
.auto-rule-toggle { margin-left: auto; }
.auto-rule-actions { display: flex; gap: 4px; margin-left: 8px; }
.auto-rule-actions button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; }
.auto-rule-actions button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.auto-create-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; width: 450px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); z-index: 1000; }
.auto-event-log { padding: 8px 0; }
.auto-event-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border-color); font-size: 12px; }
.auto-event-item:last-child { border-bottom: none; }

/* --- B6: Cleanup --- */
.cleanup-panel { padding: 16px; }
.cleanup-section { margin-bottom: 16px; }
.cleanup-section-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; text-transform: uppercase; }
.cleanup-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; margin-bottom: 4px; background: var(--bg-secondary); }
.cleanup-item-title { flex: 1; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cleanup-item-reason { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: rgba(255,107,107,0.1); color: #ff6b6b; }
.cleanup-action-btn { font-size: 12px; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-color); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.cleanup-action-btn:hover { background: var(--bg-tertiary); }
.cleanup-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; background: #ff6b6b; color: #fff; font-size: 10px; font-weight: 600; padding: 0 4px; }

/* --- B6: Export --- */
.export-dialog { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); z-index: 1000; }
.export-format-row { display: flex; gap: 8px; margin: 12px 0; }
.export-format-card { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--bg-secondary); }
.export-format-card:hover { background: var(--bg-tertiary); }
.export-format-card--selected { border-color: var(--accent-color); background: rgba(77,171,247,0.05); }
.export-format-label { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-top: 4px; }
.export-format-desc { font-size: 11px; color: var(--text-muted); }
.export-progress { margin-top: 12px; }
.export-progress-bar { width: 100%; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.export-progress-fill { height: 100%; background: var(--accent-color); border-radius: 3px; transition: width 0.3s; }

/* --- B6: Health --- */
.health-panel { padding: 16px; }
.health-metric { margin-bottom: 12px; }
.health-metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.health-bar { width: 100%; height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.health-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.health-module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.health-module-card { padding: 10px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-color); text-align: center; }
.health-module-count { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.health-module-name { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.health-module-trend { font-size: 11px; font-weight: 600; }
.health-module-trend.up { color: #69db7c; }
.health-module-trend.down { color: #ff6b6b; }
.health-storage-donut { display: flex; justify-content: center; margin: 12px 0; }

/* --- B7: Workspace --- */
.ws-scope-indicator { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; background: var(--bg-tertiary); font-size: 12px; color: var(--text-secondary); }
.ws-scope-badge { width: 8px; height: 8px; border-radius: 50%; }

/* --- B7: Permissions --- */
.perm-panel { padding: 12px 0; }
.perm-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.perm-row:last-child { border-bottom: none; }
.perm-user-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.perm-user-name { flex: 1; font-size: 13px; color: var(--text-primary); }
.perm-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.perm-share-dialog { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); z-index: 1000; }

/* --- B7: Collaboration --- */
.collab-presence-bar { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.collab-avatar { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: #fff; border: 2px solid var(--bg-primary); margin-left: -6px; }
.collab-avatar:first-child { margin-left: 0; }
.collab-avatar-stack { display: flex; align-items: center; }
.collab-avatar-overflow { width: 24px; height: 24px; border-radius: 50%; background: var(--bg-tertiary); color: var(--text-muted); font-size: 10px; display: flex; align-items: center; justify-content: center; margin-left: -6px; border: 2px solid var(--bg-primary); }
.collab-editing-indicator { position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg-primary); animation: collab-pulse 2s infinite; }
@keyframes collab-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.collab-conflict-banner { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.3); border-radius: 8px; margin-bottom: 8px; font-size: 13px; color: var(--text-primary); }
.collab-conflict-banner button { padding: 4px 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-secondary); cursor: pointer; font-size: 12px; color: var(--text-primary); }

/* --- B7: AI Memory --- */
.ai-memory-panel { padding: 12px 0; }
.ai-memory-list { display: flex; flex-direction: column; gap: 8px; }
.ai-memory-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; background: var(--bg-secondary); }
.ai-memory-key { font-size: 12px; font-weight: 600; color: var(--text-primary); min-width: 80px; }
.ai-memory-value { font-size: 12px; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-memory-confidence-bar { width: 40px; height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.ai-memory-confidence-fill { height: 100%; background: var(--accent-color); border-radius: 2px; }
.ai-memory-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.ai-memory-learn-btn { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent-color); background: transparent; color: var(--accent-color); font-size: 13px; cursor: pointer; transition: all 0.15s; margin-top: 8px; }
.ai-memory-learn-btn:hover { background: var(--accent-color); color: #fff; }
.ai-context-badge { width: 8px; height: 8px; border-radius: 50%; background: #69db7c; position: absolute; top: -2px; right: -2px; }

/* --- Shared: Modal Backdrop --- */
.eco-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }

/* --- Focus Visible --- */
.graph-filter-chip:focus-visible,
.graph-close-btn:focus-visible,
.context-item:focus-visible,
.eco-notif-bell:focus-visible,
.rec-item-action:focus-visible,
.collection-chip:focus-visible,
.cluster-create-btn:focus-visible,
.timeline-type-chip:focus-visible,
.replay-play-btn:focus-visible,
.cleanup-action-btn:focus-visible,
.auto-rule-actions button:focus-visible,
.ai-memory-learn-btn:focus-visible {
    outline: 2px solid var(--accent-color); outline-offset: 2px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .eco-notif-panel { width: 100%; right: -100%; }
    .collection-modal { width: 95vw; }
    .auto-create-modal { width: 95vw; }
    .export-dialog { width: 95vw; }
    .perm-share-dialog { width: 95vw; }
    .graph-tooltip { max-width: 180px; }
    .health-module-grid { grid-template-columns: repeat(2, 1fr); }
    .correlation-grid { grid-template-columns: 1fr; }
    .collection-grid { grid-template-columns: 1fr; }
}

/* --- Light Theme --- */
[data-theme="light"] .graph-tooltip { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
[data-theme="light"] .eco-notif-panel { box-shadow: -4px 0 16px rgba(0,0,0,0.05); }
[data-theme="light"] .eco-notif-item--unread { background: rgba(77,171,247,0.04); }
[data-theme="light"] .collection-modal { box-shadow: 0 20px 60px rgba(0,0,0,0.12); }
[data-theme="light"] .auto-create-modal { box-shadow: 0 20px 60px rgba(0,0,0,0.12); }
[data-theme="light"] .export-dialog { box-shadow: 0 20px 60px rgba(0,0,0,0.12); }
[data-theme="light"] .replay-overlay { background: #fff; }
