/* 5Why 分析工具面板 */
.why-tool-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    min-height: 0;
}

.why-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-muted, #f9fafb);
    flex-shrink: 0;
}

.why-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.why-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.why-title i { color: #6366f1; }

.why-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.why-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.why-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.why-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
}

.why-btn-primary {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border-color: transparent;
    color: #fff !important;
}

.why-btn-primary:hover {
    opacity: 0.88;
    border-color: transparent !important;
}

.why-canvas-wrap {
    flex: 1;
    overflow: auto;
    padding: 20px 16px;
    background-color: #f3f4f6;
    background-image: radial-gradient(circle, #d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
    min-height: 520px;
}

.why-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 236px;
    gap: 28px;
    align-items: start;
    max-width: 1060px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    min-height: 680px;
}

.why-flow {
    min-width: 0;
}

/* 阶梯式缩进 */
.why-block,
.why-row,
.why-connector-v {
    margin-left: calc(var(--why-step, 0) * 48px);
}

.why-block,
.why-row {
    margin-bottom: 8px;
}

.why-connector-v {
    display: block;
    width: 40px;
    height: 24px;
    margin-bottom: 2px;
    margin-top: -4px;
    opacity: 0.9;
}

.why-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.why-block {
    position: relative;
    width: 280px;
    padding: 28px 14px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.why-label {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.02em;
}

/* 问题块 */
.why-block-problem {
    background: #fecaca;
    border: 2px solid #fca5a5;
    margin-bottom: 20px;
}

.why-block-problem .why-label { color: #b91c1c; }

/* 为什么块 */
.why-block-question {
    background: #e5e7eb;
    border: 2px solid #d1d5db;
    flex-shrink: 0;
}

.why-block-question .why-label { color: #475569; }

/* 原因块 */
.why-block-reason {
    background: #fff;
    border: 2px solid #f87171;
    flex-shrink: 0;
}

.why-block-reason .why-label { color: #dc2626; }

/* 根因块 */
.why-block-root {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.why-block-root .why-label { color: #7c3aed; }

/* 解决措施块 */
.why-block-action {
    background: #fde047;
    border: 2px solid #facc15;
    margin-top: 16px;
    width: 320px;
}

.why-block-action .why-label { color: #a16207; }

/* 便签 */
.why-sticky {
    min-height: 56px;
    padding: 10px 12px;
    background: #fef9c3;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
    font-size: 0.82rem;
    line-height: 1.55;
    color: #1e293b;
    outline: none;
    word-break: break-word;
    cursor: text;
    transition: box-shadow 0.15s;
}

.why-sticky:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
}

.why-sticky:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.why-arrow {
    width: 48px;
    height: 32px;
    flex-shrink: 0;
    margin-top: 36px;
    opacity: 0.85;
}

/* 方法论提示（右侧独立栏，避免与流程块重叠） */
.why-hints {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
    pointer-events: none;
}

.why-hint {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.55;
    color: #334155;
}

.why-hint-num {
    flex-shrink: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6366f1;
    line-height: 1.45;
}

.why-hint-title {
    flex-shrink: 0;
    font-weight: 700;
    color: #1e293b;
}

.why-hint-desc {
    flex: 1;
    min-width: 0;
    color: #64748b;
    font-size: 0.76rem;
}
/* 响应式 */
@media (max-width: 960px) {
    .why-board {
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 100%;
    }

    .why-hints {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .why-board {
        padding: 16px 8px 32px;
    }

    .why-block,
    .why-row,
    .why-connector-v {
        margin-left: calc(var(--why-step, 0) * 24px);
    }

    .why-block {
        width: 220px;
    }

    .why-block-action {
        width: 240px;
    }

    .why-arrow {
        width: 28px;
    }

    .why-hints {
        display: none;
    }
}

@media (min-width: 961px) and (max-width: 1100px) {
    .why-block {
        width: 252px;
    }

    .why-row {
        gap: 6px;
    }

    .why-arrow {
        width: 40px;
    }
}
