/* ═══════════ MarkPanel 统一标记面板 ═══════════ */

/* ── 遮罩层 ─────────────────────────────────── */
.bk-mp-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-strong, rgba(44, 24, 16, 0.38));
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bk-mp-overlay.bk-mp-visible {
    opacity: 1;
    pointer-events: auto;
    touch-action: none;
}

/* ── 抽屉主体 ───────────────────────────────── */
.bk-mp-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--surface, #fff);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border, #E5E2DD);
    overscroll-behavior: contain;
}
.bk-mp-drawer.bk-mp-visible {
    transform: translateX(0);
}

/* ── Header ─────────────────────────────────── */
.bk-mp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--border, #E5E2DD);
    flex-shrink: 0;
    gap: 8px;
}
.bk-mp-header-title {
    flex: 1;
    min-width: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--heading, #111);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding-right: 14px;
}

/* ── Tab 栏 ─────────────────────────────────── */
.bk-mp-tabs {
    display: flex;
    border-bottom: 1px solid var(--border, #E5E2DD);
    flex-shrink: 0;
    padding: 0 12px;
}
.bk-mp-tab-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    color: var(--text-muted, #9A958C);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}
.bk-mp-tab-btn.active {
    color: var(--brand, #3D8A5A);
    font-weight: 600;
}
.bk-mp-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--brand, #3D8A5A);
    border-radius: 1px;
}
.bk-mp-tab-btn:active {
    opacity: 0.7;
}

/* ── 搜索框（目录 Tab）────────────────────── */
.bk-mp-search {
    flex-shrink: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border, #E5E2DD);
}
.bk-mp-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--border, #E5E2DD);
    border-radius: 8px;
    font-size: var(--text-base);
    outline: none;
    background: var(--surface-alt, #EDEAE4);
    color: var(--text, #1A1918);
    transition: border-color 0.15s;
}
.bk-mp-search-input:focus {
    border-color: var(--brand, #3D8A5A);
}
.bk-mp-search-input::placeholder {
    color: var(--text-muted, #aaa);
}

/* ── 筛选栏（标记 Tab）────────────────────── */
.bk-mp-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border, #E5E2DD);
    flex-shrink: 0;
}
.bk-mp-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid var(--border, #E5E2DD);
    background: var(--surface, #fff);
    color: var(--text-muted, #9A958C);
    font-size: var(--text-xs);
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.bk-mp-filter-tag.active {
    background: var(--brand, #3D8A5A);
    color: #fff;
    border-color: var(--brand, #3D8A5A);
}
.bk-mp-filter-tag:active {
    opacity: 0.7;
}

/* ── 内容区域 ───────────────────────────────── */
.bk-mp-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.bk-mp-tab-pane {
    display: none;
}
.bk-mp-tab-pane.active {
    display: block;
}

/* ── 通用列表样式 ────────────────────────────── */
.bk-mp-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.bk-mp-item {
    display: flex;
    align-items: stretch;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
    border-bottom: 1px solid var(--border, #E5E2DD);
}
.bk-mp-item:active {
    background: var(--nav-hover, #ECEAE5);
}

/* 左侧颜色条 */
.bk-mp-color-bar {
    width: 4px;
    min-height: 100%;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}

/* 内容区 */
.bk-mp-item-content {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
}
.bk-mp-item-title {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--heading, #1A1918);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-all;
}
.bk-mp-item-meta {
    font-size: var(--text-xs);
    color: var(--text-muted, #9A958C);
    margin-top: 3px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bk-mp-item-note {
    font-size: var(--text-xs);
    color: var(--text-muted, #9A958C);
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--border, #E5E2DD);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

/* 删除按钮（左滑出现）*/
.bk-mp-item-delete {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: var(--color-danger, #E54D42);
    color: #fff;
    border: none;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.bk-mp-item-delete:active {
    opacity: 0.85;
}

/* 空状态 */
.bk-mp-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted, #9A958C);
    font-size: var(--text-base);
    line-height: 1.6;
}

/* ── Footer ─────────────────────────────────── */
.bk-mp-footer {
    border-top: 1px solid var(--border, #E5E2DD);
    padding: 10px 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.bk-mp-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 20px;
    border: 1.5px solid var(--brand, #3D8A5A);
    background: none;
    color: var(--brand, #3D8A5A);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
}
.bk-mp-add-btn:active {
    background: var(--brand, #3D8A5A);
    color: #fff;
}
.bk-mp-add-btn.bk-mp-add-active {
    background: var(--brand, #3D8A5A);
    color: #fff;
}
.bk-mp-stats {
    font-size: var(--text-xs);
    color: var(--text-muted, #9A958C);
}

/* ── TOC 平铺列表（EPUB）────────────────────── */
.bk-mp-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.bk-mp-toc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    text-decoration: none;
    color: var(--text, #1A1918);
    font-size: var(--text-base);
    border-bottom: 1px solid var(--border, #E5E2DD);
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}
.bk-mp-toc-item:active { background: var(--nav-hover, #ECEAE5); }
.bk-mp-toc-item.bk-mp-toc-current {
    background: var(--nav-hover, #ECEAE5);
    color: var(--brand, #3D8A5A);
    font-weight: 500;
}
.bk-mp-toc-num {
    font-size: var(--text-xs);
    font-family: var(--num-font-family);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #888);
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}
.bk-mp-toc-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05em;
    line-height: 1.4;
}
.bk-mp-toc-badge {
    font-size: var(--text-xs);
    background: var(--brand, #3D8A5A);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
}

/* ── TOC 树形列表（PDF）────────────────────── */
.bk-mp-toc-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}
.bk-mp-toc-tree-item {
    border-bottom: 1px solid var(--border, #E5E2DD);
}
.bk-mp-toc-tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.bk-mp-toc-tree-row:active { background: var(--nav-hover, #ECEAE5); }
.bk-mp-toc-tree-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    font-size: 0.75em;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.bk-mp-toc-tree-toggle:empty {
    visibility: hidden;
}
.bk-mp-toc-tree-title {
    flex: 1;
    font-size: var(--text-base);
    color: var(--text, #1A1918);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bk-mp-toc-tree-page {
    font-size: var(--text-xs);
    color: var(--text-muted, #888);
    flex-shrink: 0;
    margin-left: 8px;
}
.bk-mp-toc-tree-children {
    display: none;
}
.bk-mp-toc-tree-children.bk-mp-expanded {
    display: block;
}

/* ── 编辑弹窗 ────────────────────────────────── */
.bk-mp-edit-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-medium, rgba(0,0,0,0.3));
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.bk-mp-edit-dialog {
    background: var(--surface, #fff);
    border-radius: 16px;
    width: min(360px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.bk-mp-edit-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #E5E2DD);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--heading, #1A1918);
    text-align: center;
}
.bk-mp-edit-body {
    padding: 16px;
}
.bk-mp-edit-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border, #E5E2DD);
    border-radius: 8px;
    font-size: var(--text-base);
    outline: none;
    color: var(--text, #1A1918);
    background: var(--surface, #fff);
    line-height: 1.5;
    resize: vertical;
}
.bk-mp-edit-input:focus {
    border-color: var(--brand, #3D8A5A);
}
textarea.bk-mp-edit-input {
    min-height: 80px;
}
.bk-mp-edit-actions {
    display: flex;
    border-top: 1px solid var(--border, #E5E2DD);
}
.bk-mp-edit-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    color: var(--brand, #3D8A5A);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.bk-mp-edit-btn:active { background: var(--nav-hover, #ECEAE5); }
.bk-mp-edit-btn + .bk-mp-edit-btn {
    border-left: 1px solid var(--border, #E5E2DD);
}
.bk-mp-edit-btn.bk-mp-edit-destructive {
    color: var(--color-danger, #E54D42);
}

/* ── 响应式 ─────────────────────────────────── */
@media (max-width: 360px) {
    .bk-mp-drawer { width: 100vw; max-width: 100vw; }
    .bk-mp-filter-tag { padding: 3px 8px; font-size: 11px; }
}

@media (min-width: 768px) {
    .bk-mp-drawer { width: 380px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    .bk-mp-header { padding: 8px 14px; }
    .bk-mp-tabs { padding: 0 12px; }
    .bk-mp-tab-btn { padding: 6px 0; }
}
