/* Paper insights popups (assets/js/paper-insights.js) */
.paper-actions li a.pa-graph { background: #4a4e6b; }
.paper-actions li a.pa-mindmap { background: #b83227; }
.paper-actions li a.pa-qa { background: #4553b0; }

.pi-modal {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .55);
    opacity: 0;
    transition: opacity .2s ease;
}
.pi-modal.is-open { opacity: 1; }

.pi-box {
    width: min(1280px, 100%);
    height: min(820px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
    overflow: hidden;
}

.pi-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px 12px;
}
.pi-head h3 { margin: 0; font-size: 22px; font-weight: 700; color: #1f2937; white-space: nowrap; }
.pi-note {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid #f3e3a1;
    border-radius: 8px;
    background: #fffbea;
    color: #5b4a12;
    font-size: 14px;
    font-weight: 600;
}
.pi-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #6b7280;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.pi-close:hover { background: #f3f4f6; color: #111827; }

.pi-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 20px;
    margin: 0 20px;
    padding: 10px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    font-size: 15px;
    color: #1f2937;
}
.pi-filters span { margin-right: auto; }
.pi-filters label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.pi-filters input { width: 17px; height: 17px; accent-color: #2563eb; }

.pi-body { position: relative; flex: 1; min-height: 0; padding: 4px 8px 8px; }
.pi-chart { width: 100%; height: 100%; }
.pi-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #6b7280;
    font-size: 15px;
}

@media (max-width: 767.98px) {
    .pi-modal { padding: 0; }
    .pi-box { height: 100vh; height: 100dvh; border-radius: 0; }
    .pi-head { flex-wrap: wrap; padding: 12px 14px 8px; }
    .pi-head h3 { font-size: 18px; }
    .pi-note { order: 3; flex-basis: 100%; font-size: 12px; }
    .pi-close { margin-left: auto; }
    .pi-filters { margin: 0 12px; font-size: 13px; justify-content: flex-start; }
    .pi-filters span { flex-basis: 100%; }
}

/* Mind map */
.pi-body.is-map { padding: 0; }
.pi-map { width: 100%; height: 100%; display: block; }
.pi-tools {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 2;
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.pi-tools button {
    width: 34px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #4b5563;
    font-size: 15px;
    cursor: pointer;
}
.pi-tools button:hover { background: #f3f4f6; color: #111827; }
.pi-state small { color: #9ca3af; }
.pi-head .pi-ai { flex: 0 0 auto; color: #b83227; font-size: 22px; }

/* AI Q&A side panel */
.qa-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1085;
    width: min(440px, 100vw);
    display: flex;
    flex-direction: column;
    background: #eef3fc;
    border-top: 4px solid #4553b0;
    box-shadow: -12px 0 40px rgba(15, 23, 42, .25);
    transform: translateX(100%);
    transition: transform .25s ease;
    font-size: 15px;
    color: #1f2937;
}
.qa-panel.is-open { transform: none; }
.qa-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.qa-logo { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #6d5dfc, #4553b0); color: #fff; font-size: 17px; }
.qa-title { flex: 1; min-width: 0; font-weight: 700; }
.qa-title small { display: block; font-weight: 400; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: #4553b0; font-size: 20px; cursor: pointer; }
.qa-x:hover { background: #dfe6f7; }
.qa-note { margin: 0 16px 8px; font-size: 12.5px; color: #8a94a6; }
.qa-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; }
.qa-sum-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.qa-sum-head b { font-size: 17px; }
.qa-toggle { border: 0; border-radius: 6px; padding: 4px 10px; background: #4553b0; color: #fff; font-size: 13px; cursor: pointer; }
.qa-summary ol { margin: 0; padding-left: 20px; }
.qa-summary li { margin-bottom: 12px; line-height: 1.6; }
.qa-summary li b { display: block; }
.qa-msg { margin: 12px 0; line-height: 1.55; }
.qa-msg.is-user { margin-left: 40px; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: #4553b0; color: #fff; }
.qa-msg.is-bot { margin-right: 20px; padding: 11px 13px; border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.qa-answer { font-weight: 700; font-size: 16px; }
.qa-src { margin-top: 8px; padding: 8px 10px; border-left: 3px solid #c7d0ee; background: #f6f8fd; font-size: 13.5px; color: #4b5563; }
.qa-src mark { background: #fff1a8; padding: 0 1px; }
.qa-src small { display: block; margin-bottom: 3px; color: #6b7280; font-weight: 600; }
.qa-more { margin-top: 6px; border: 0; background: none; padding: 0; color: #4553b0; font-size: 13px; cursor: pointer; }
.qa-status { font-size: 13px; color: #6b7280; }
.qa-bar { height: 5px; margin-top: 6px; border-radius: 99px; background: #dbe2f3; overflow: hidden; }
.qa-bar span { display: block; height: 100%; width: 0; background: #4553b0; transition: width .2s; }
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.qa-chips button { border: 1px solid #c7d0ee; border-radius: 99px; padding: 4px 10px; background: #fff; color: #4553b0; font-size: 12.5px; cursor: pointer; }
.qa-form { display: flex; gap: 8px; padding: 12px 16px 16px; }
.qa-form input { flex: 1; min-width: 0; height: 48px; padding: 0 18px; border: 1px solid #c7d0ee; border-radius: 99px; font-size: 15px; background: #fff; }
.qa-form input:focus { outline: 2px solid #8fa0e6; border-color: transparent; }
.qa-form button { height: 48px; padding: 0 22px; border: 0; border-radius: 99px; background: linear-gradient(135deg, #5b6fd6, #4553b0); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.qa-form button:disabled { opacity: .6; cursor: default; }

.qa-ai p { margin: 0 0 8px; }
.qa-ai p:last-child { margin-bottom: 0; }
.qa-list { margin: 0 0 8px; padding-left: 18px; }
.qa-list li { margin-bottom: 4px; }
