/* 划词批注（灰度） */
.card-head-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.anno-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    border-radius: 8px;
    padding: 6px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.anno-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.anno-toggle [data-anno-count] {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.anno-hint {
    margin: 0 0 14px;
    padding: 8px 12px;
    border: 1px dashed #d7e3f7;
    border-radius: 8px;
    background: #f8fbff;
    color: var(--muted);
    font-size: 12.5px;
}

/* 高亮层不拦截鼠标，否则正文无法继续选中 */
.content-body.r6o-annotatable .r6o-span-highlight-layer {
    pointer-events: none;
}

/* 法规正文里的长串点线没有断行机会，窄屏下会撑出横向滚动条 */
.content-body.markdown-body {
    overflow-wrap: anywhere;
}

/* 抽屉 */
.anno-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.anno-drawer-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 27, 48, .16);
}

.anno-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(420px, 100%);
    height: 100%;
    background: #fff;
    box-shadow: -8px 0 30px rgba(16, 35, 70, .14);
}

.anno-drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--line);
}

.anno-drawer-head strong {
    display: block;
    font-size: 16px;
}

.anno-drawer-sub {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.anno-drawer-close {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.anno-drawer-close:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.anno-drawer-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.anno-export {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--primary);
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.anno-export:hover {
    border-color: var(--primary);
    background: #f2f7ff;
}

.anno-filters {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}

.anno-filters button {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    border-radius: 999px;
    padding: 5px 12px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.anno-filters button.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.anno-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.anno-empty {
    padding: 24px 6px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.anno-card {
    border: 1px solid var(--line);
    border-left: 3px solid #e8b400;
    border-radius: 9px;
    padding: 12px 12px 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.anno-card.is-question {
    border-left-color: #f08a24;
}

.anno-card.is-note {
    border-left-color: #7c4dff;
}

.anno-card.is-highlight {
    border-left-color: #e53935;
}

.anno-card.is-unlocated {
    border-left-color: #c2cbd9;
    opacity: .85;
}

.anno-card.is-jumpable {
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.anno-card.is-target {
    border-color: #1E6FFF;
    box-shadow: 0 0 0 3px rgba(30, 111, 255, .18);
}

.anno-card.is-jumpable:hover {
    border-color: #c9d8ef;
    box-shadow: 0 4px 16px rgba(23, 43, 84, .09);
}

.anno-card.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 111, 255, .14), var(--shadow-sm);
}

.anno-card.is-active .anno-card-quote {
    background: #eaf2ff;
    color: #174ea6;
}

@keyframes annoCardFlash {
    0% { box-shadow: 0 0 0 0 rgba(30, 111, 255, .4); }
    70% { box-shadow: 0 0 0 8px rgba(30, 111, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(30, 111, 255, 0); }
}

.anno-card.is-flash {
    animation: annoCardFlash .9s ease-out;
}

/* 定位后短暂标记正文目标段落 */
.anno-jump-target {
    background: rgba(255, 213, 79, .24);
    outline: 2px solid #f0a400;
    outline-offset: 3px;
    border-radius: 4px;
    transition: background .2s ease;
}

.anno-card-quote {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #fff9e6;
    color: #8a6a00;
    font-size: 12px;
    line-height: 1.55;
    cursor: pointer;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anno-card.is-note .anno-card-quote {
    background: #f3efff;
    color: #5b3bb5;
}

.anno-card.is-question .anno-card-quote {
    background: #fff2e6;
    color: #9a5200;
}

.anno-card-body {
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.anno-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 9px;
    color: var(--muted);
    font-size: 11.5px;
}

.anno-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f5fb;
    color: var(--ink-2);
    font-size: 11px;
}

.anno-badge.question {
    background: #fff1e2;
    color: #b46300;
}

.anno-badge.note {
    background: #f2ecff;
    color: #5b3bb5;
}

.anno-badge.public {
    background: #e8f1ff;
    color: #2456a8;
}

.anno-badge.highlight {
    background: #ffebee;
    color: #c62828;
}

.anno-toggle.is-active {
    border-color: #c62828;
    color: #c62828;
    background: #fff5f5;
}

/* 选中文字后的快捷操作条 */
.anno-quickbar {
    position: fixed;
    z-index: 2400;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 30, 60, 0.16);
}

.anno-quick {
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    padding: 7px 12px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
}

.anno-quick:hover {
    background: #f4f7fc;
}

.anno-quick[data-anno-quick="highlight"] {
    color: #c62828;
}

.anno-quick[data-anno-quick="highlight"]:hover {
    background: #ffebee;
}

.anno-quick-cancel {
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font-size: 16px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 7px;
}

.anno-quick-cancel:hover {
    background: #f4f7fc;
}

.anno-card-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.anno-card-actions button,
.anno-reply-toggle {
    border: 0;
    background: none;
    padding: 0;
    color: var(--primary);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.anno-card-actions button:hover,
.anno-reply-toggle:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.anno-card-actions button.danger {
    color: #b42318;
}

.anno-replies {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anno-reply {
    padding: 8px 10px;
    border-radius: 7px;
    background: #f7f9fc;
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.anno-reply-meta {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
}

.anno-reply-form {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.anno-reply-form textarea {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 9px;
    font: inherit;
    font-size: 12.5px;
}

.anno-reply-form button {
    align-self: flex-end;
}

/* 批注 / 笔记 / 提问修改 */
.anno-edit-form {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anno-edit-input {
    width: 100%;
    min-height: 84px;
    max-height: 240px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 8px 10px;
    font: inherit;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--ink);
    background: #fff;
}

.anno-edit-input:focus {
    outline: none;
    border-color: #1E6FFF;
    box-shadow: 0 0 0 3px rgba(30, 111, 255, .12);
}

.anno-edit-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.anno-edit-foot button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    border-radius: 7px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}

.anno-edit-save {
    border-color: #1E6FFF;
    background: #1E6FFF;
    color: #fff;
}

.anno-edit-save:disabled {
    opacity: .6;
    cursor: default;
}

.anno-edit-error {
    color: #c62828;
    font-size: 12px;
}

.anno-drawer-foot {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

/* 批注编辑气泡 */
.anno-composer {
    position: fixed;
    z-index: 1100;
    width: min(380px, calc(100vw - 24px));
    padding: 14px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 16px 46px rgba(16, 35, 70, .22);
}

.anno-composer-quote {
    max-height: 72px;
    margin-bottom: 10px;
    padding: 7px 9px;
    overflow: auto;
    border-radius: 7px;
    background: #fff9e6;
    color: #8a6a00;
    font-size: 12px;
    line-height: 1.55;
}

.anno-composer textarea {
    width: 100%;
    min-height: 96px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    font: inherit;
    font-size: 14px;
    line-height: 1.7;
}

.anno-composer-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 9px;
    color: var(--ink-2);
    font-size: 12.5px;
}

.anno-composer-options label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.anno-composer-error {
    margin-top: 8px;
    color: #b42318;
    font-size: 12.5px;
}

.anno-composer-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.anno-composer-foot button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 7px 14px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.anno-composer-foot button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.anno-composer-foot button.primary:hover {
    background: var(--primary-dark);
}

@media (max-width: 720px) {
    .anno-drawer-panel {
        width: 100%;
    }

    .anno-composer {
        left: 12px !important;
        right: 12px;
        top: auto !important;
        bottom: 12px;
        width: auto;
    }

    .anno-composer textarea {
        min-height: 88px;
    }

    .anno-hint {
        margin-bottom: 10px;
    }
}
