@charset "utf-8";

/* =========================================================================
   Paperline PDF 查看器 - 统一样式表
   设计语言：克制、功能优先的工具型 UI
   单一强调色 (靛蓝)，单一圆角系统，统一毛玻璃 chrome
   ========================================================================= */

:root {
    color-scheme: light;

    /* 文本 */
    --ink: #17212b;
    --muted: #718092;
    --muted-strong: #526174;

    /* 强调色（单一，全局锁定） */
    --accent: #4669d8;
    --accent-deep: #2d4eb7;
    --accent-soft: #edf2ff;
    --accent-glow: rgb(70 105 216 / 24%);

    /* 表面 */
    --surface: #fbfcfe;
    --surface-raised: #ffffff;
    --workspace: #e8edf3;
    --workspace-deep: #dfe5ec;

    /* 统一毛玻璃 chrome 层 */
    --chrome: rgb(248 250 253 / 90%);
    /* 固定全宽栏：更高不透明度 + 更轻模糊，降低滚动时 backdrop-filter 重算开销 */
    --chrome-bar: rgb(248 250 253 / 96%);
    --chrome-solid: rgb(252 253 254);
    --chrome-border: rgb(203 212 224 / 65%);
    --chrome-border-strong: #d7deeb;
    --chrome-shadow: rgb(55 69 88 / 12%);

    /* 交互态 */
    --hover-bg: #f0f3f8;
    --hover-bg-strong: #e7edf6;
    --line: #e5eaf1;
    --line-soft: #eef1f6;

    /* 圆角系统（单一刻度） */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;

    /* 尺寸 */
    --toolbar-height: 82px;
    --header-height: 48px;

    /* 触感动效（单一曲线） */
    --ease: cubic-bezier(.22, .8, .28, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --dur-1: .18s;
    --dur-2: .25s;
    --dur-3: .4s;

    font-synthesis: none;
}

*, ::after, ::before { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
    overflow: hidden;
    color: var(--ink);
    background: var(--workspace);
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button {
    border: 0;
    margin: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: wait; }
ul, li { margin: 0; padding: 0; list-style: none; }
a, a:hover, a:active, a:visited, a:link { color: inherit; text-decoration: none; }

/* =========================================================================
   Header
   ========================================================================= */
.app-header {
    position: fixed;
    z-index: 200;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-height);
    padding: 0 clamp(16px, 3vw, 44px);
    border-bottom: 1px solid var(--chrome-border);
    background: var(--chrome-bar);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
}
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: var(--ink);
    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 5px 12px rgb(23 33 43 / 16%);
}
.brand-name { margin: 0; font-size: 14px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.brand-caption { margin: 2px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .05em; }

.document-context {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    justify-content: center;
    color: var(--muted-strong);
    font-size: 13px;
}
.document-context #document-name {
    max-width: min(42vw, 520px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.context-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #63b997;
    box-shadow: 0 0 0 4px #e6f5ef;
}

.floating-upload-button {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 7px;
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid var(--chrome-border-strong);
    border-radius: 999px;
    color: var(--accent-deep);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgb(65 79 105 / 9%);
    transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.floating-upload-button:hover { border-color: #aab9e3; box-shadow: 0 8px 20px rgb(65 79 105 / 14%); transform: translateY(-1px); }
.floating-upload-button:active { transform: translateY(1px) scale(.98); }
.upload-icon {
    display: inline-grid;
    width: 18px;
    height: 18px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    font-size: 17px;
    font-weight: 400;
    line-height: 1;
}

/* =========================================================================
   页面布局
   ========================================================================= */
#page {
    display: flex;
    width: 100%;
    height: 100%;
    padding-top: var(--header-height);
    overflow: hidden;
}
#viewer-container {
    position: relative;
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    overflow: auto;
    overflow-x: hidden;
    overscroll-behavior-x: contain;
    outline: none;
    background:
        radial-gradient(circle at 50% -20%, rgb(255 255 255 / 76%), transparent 50%),
        var(--workspace);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #b7c1cf transparent;
}
#viewer-container:focus-visible { box-shadow: inset 0 0 0 3px var(--accent-glow); }

.page-container {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 100px;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 16px 42px rgb(55 69 88 / 16%), 0 2px 5px rgb(55 69 88 / 10%);
    direction: ltr;
    contain: paint;
}
.page-container + .page-container { margin-top: 18px; }
.page-canvas { position: relative; z-index: 1; display: block; width: 100%; height: auto; }
.draw-canvas { position: absolute; z-index: 2; inset: 0; width: 100%; height: auto; margin: 0 auto; }

/* 占位静态外观（离屏页也有，但不跑动画，省 CPU/GPU） */
.page-container.loading {
    background: #f5f7fa;
}
/* 仅对进入视口的加载页启用 shimmer + spinner 动画（由 IntersectionObserver 切换 loading-visible） */
.page-container.loading.loading-visible {
    background: linear-gradient(110deg, #f5f7fa 8%, #fff 18%, #f5f7fa 33%);
    background-size: 220% 100%;
    animation: page-shimmer 1.6s var(--ease) infinite;
}
.page-container.loading::before {
    content: "";
    position: absolute;
    inset: 14% 10%;
    border-radius: 5px;
    background: repeating-linear-gradient(to bottom, rgb(130 145 165 / 14%) 0 2px, transparent 2px 20px);
    opacity: .55;
}
.page-container.loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 26px; height: 26px;
    border: 2px solid #cbd4e1;
    border-top-color: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.page-container.loading.loading-visible::after {
    animation: page-spinner .9s linear infinite;
}
@keyframes page-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes page-spinner { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* =========================================================================
   页码指示器
   ========================================================================= */
.page-num {
    position: fixed;
    z-index: 140;
    top: calc(var(--header-height) + 18px);
    right: clamp(14px, 3vw, 38px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid rgb(255 255 255 / 85%);
    border-radius: 999px;
    color: var(--ink);
    background: var(--chrome);
    box-shadow: 0 7px 18px var(--chrome-shadow);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    font-size: 13px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color var(--dur-2) var(--ease);
}
.page-num .current-page { font-size: 16px; font-weight: 800; color: var(--accent-deep); }
.page-num .page-line { color: #b6bfcc; font-weight: 500; }
.page-num .total-page { color: var(--muted-strong); font-weight: 600; }

/* =========================================================================
   工具栏
   ========================================================================= */
#toolbar {
    position: fixed;
    z-index: 180;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--toolbar-height);
    padding: 8px clamp(10px, 3vw, 40px);
    border-top: 1px solid var(--chrome-border);
    background: var(--chrome-bar);
    box-shadow: 0 -12px 28px rgb(57 70 88 / 10%);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
}
#toolbar .btn-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: min(112px, 12vw);
    height: 58px;
    border-radius: var(--radius-md);
    color: var(--muted-strong);
    transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
#toolbar .btn-wrap:hover { color: var(--ink); background: var(--hover-bg); }
#toolbar .btn-wrap:active { transform: translateY(1px) scale(.98); }
#toolbar .btn-wrap.active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 18px var(--accent-glow);
}
#toolbar .btn-wrap.disabled { opacity: .36; pointer-events: none; }
#toolbar .btn-icon {
    display: block;
    width: 23px;
    height: 23px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: filter var(--dur-1) var(--ease);
}
#toolbar .btn-text { font-size: 13px; font-weight: 650; white-space: nowrap; }
#toolbar #sign .btn-icon { background-image: url('../../static/icon/sign.png'); }
#toolbar #sign.active > .btn-icon { background-image: url('../../static/icon/sign-active.png'); }

/* =========================================================================
   遮罩与对话框
   ========================================================================= */
.mask {
    position: fixed;
    z-index: 9990;
    inset: 0;
    background: rgb(20 28 38 / 50%);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.dialog {
    position: fixed;
    z-index: 10000;
    top: 50%;
    left: 50%;
    display: none;
    width: min(500px, calc(100vw - 32px));
    max-height: min(720px, calc(100dvh - 32px));
    overflow: auto;
    border: 1px solid rgb(255 255 255 / 92%);
    border-radius: var(--radius-xl);
    color: var(--ink);
    background: var(--surface-raised);
    box-shadow: 0 28px 70px rgb(21 34 52 / 28%), 0 3px 8px rgb(21 34 52 / 8%);
    transform: translate(-50%, -50%);
    scrollbar-width: thin;
    scrollbar-color: #c2cad6 transparent;
}
.dialog .dialog-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 23px 24px 17px;
    border-bottom: 1px solid var(--line);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.025em;
}
.dialog-kicker {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.dialog .dialog-content { min-height: 80px; padding: 22px 24px; font-size: 14px; line-height: 1.6; }
.dialog .btn-wrap {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 13px 20px 16px;
    border-top: 1px solid var(--line);
    background: #fbfcfe;
}
.dialog .btn-wrap .btn {
    min-height: 40px;
    padding: 0 17px;
    border: 1px solid var(--chrome-border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.dialog .btn-wrap .btn:hover { border-color: #b9c5db; background: #f5f7fb; }
.dialog .btn-wrap .btn:active { transform: translateY(1px) scale(.98); }

.dialog-fadeIn { animation: dialog-in var(--dur-2) var(--ease-out); }
.dialog-fadeOut { animation: dialog-out .2s var(--ease) forwards; }
@keyframes dialog-in {
    from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(.98); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes dialog-out {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(.98); }
}

/* =========================================================================
   打开源对话框
   ========================================================================= */
.dialog.test-source .dialog-content { display: flex; flex-direction: column; gap: 8px; }
.dialog.test-source label { color: var(--muted-strong); font-size: 12px; font-weight: 750; }
.dialog.test-source input[type="text"],
.dialog.test-source input[type="file"] {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d6deea;
    border-radius: var(--radius-sm);
    color: var(--ink);
    background: #fbfcfe;
    transition: border var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.dialog.test-source input[type="text"]:focus,
.dialog.test-source input[type="file"]:focus,
.dialog.goto .goto-num:focus {
    outline: none;
    border-color: #8298de;
    box-shadow: 0 0 0 4px var(--accent-glow);
}
.test-source-hint, .test-source-file-name, .test-source-error { margin: 0; font-size: 12px; line-height: 1.5; }
.test-source-hint { color: var(--muted); }
.test-source-file-name { min-height: 18px; color: var(--muted-strong); overflow-wrap: anywhere; }
.test-source-error { min-height: 18px; color: #b42318; }
.test-source-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 7px 0;
    color: #a1aab8;
    font-size: 11px;
}
.test-source-divider::before, .test-source-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}
.test-source-actions { display: flex; gap: 9px; margin-top: 8px; }
.test-source-actions .btn {
    position: relative;
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--chrome-border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    background: #fff;
    font-weight: 750;
    transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.test-source-actions .test-source-preview {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
    box-shadow: 0 7px 16px var(--accent-glow);
}
.test-source-actions .btn:hover { transform: translateY(-1px); }
.test-source-actions .btn:active { transform: translateY(1px) scale(.98); }

/* =========================================================================
   缩放对话框
   ========================================================================= */
.dialog.zoom .dialog-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dialog.zoom .dialog-content .item {
    display: flex;
    min-height: 128px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--ink);
    background: #f8faff;
    text-align: left;
    transition: border var(--dur-1) var(--ease), background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.dialog.zoom .dialog-content .item:hover { transform: translateY(-2px); border-color: #bdc9e8; }
.dialog.zoom .dialog-content .item.on {
    border: 2px solid var(--accent);
    background: var(--accent-soft);
}
.dialog.zoom .dialog-content .title { font-size: 16px; font-weight: 800; }
.dialog.zoom .dialog-content .description { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* =========================================================================
   跳转对话框
   ========================================================================= */
.dialog.goto .dialog-content { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.dialog.goto .dialog-content .page-info { width: 100%; margin: 0 0 5px; color: var(--muted); font-size: 13px; }
.dialog.goto .dialog-content .page-info span { color: var(--ink); font-weight: 800; }
.dialog.goto .dialog-content .btn {
    min-height: 40px;
    padding: 0 13px;
    border: 1px solid var(--chrome-border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.dialog.goto .dialog-content .btn:hover { border-color: #b9c5db; background: #f5f7fb; }
.dialog.goto .dialog-content .btn:active { transform: translateY(1px) scale(.98); }
.dialog.goto .dialog-content .goto-num-label { margin-left: auto; color: var(--muted); font-size: 13px; }
.dialog.goto .dialog-content .goto-num {
    width: 68px;
    min-height: 40px;
    padding: 0 9px;
    border: 1px solid #d6deea;
    border-radius: var(--radius-sm);
    color: var(--ink);
    background: #fbfcfe;
    text-align: center;
}
.dialog.goto .dialog-content #btn-goto-num-page {
    color: #fff;
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 6px 14px var(--accent-glow);
}

/* =========================================================================
   护眼模式对话框
   ========================================================================= */
.dialog.eye .dialog-content { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; padding: 25px 24px; }
.dialog.eye .dialog-content .warp {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 2px;
    border-radius: var(--radius-md);
    color: var(--muted);
    font-size: 11px;
    transition: transform var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.dialog.eye .dialog-content .warp:hover { color: var(--ink); transform: translateY(-2px); }
.dialog.eye .dialog-content .warp:active { transform: translateY(0) scale(.97); }
.dialog.eye .dialog-content .color-wrap {
    display: block;
    width: 58px;
    height: 58px;
    border: 2px solid rgb(23 33 43 / 10%);
    border-radius: 50%;
    box-shadow: inset 0 0 0 4px #fff, 0 4px 12px rgb(37 48 63 / 13%);
    transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.dialog.eye .dialog-content .warp.on { color: var(--accent-deep); font-weight: 750; }
.dialog.eye .dialog-content .warp.on .color-wrap {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 4px #fff, 0 0 0 4px var(--accent-glow), 0 5px 14px var(--accent-glow);
}

/* =========================================================================
   加载遮罩
   ========================================================================= */
.viewer-loading {
    position: fixed;
    z-index: 220;
    inset: var(--header-height) 0 var(--toolbar-height);
    display: grid;
    place-items: center;
    background: rgb(232 237 243 / 70%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease);
}
.viewer-loading.is-visible { opacity: 1; pointer-events: auto; }
.loading-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 245px;
    padding: 17px 20px;
    border: 1px solid rgb(255 255 255 / 90%);
    border-radius: var(--radius-md);
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 16px 38px var(--chrome-shadow);
}
.loading-orbit { position: relative; width: 32px; height: 32px; border: 2px solid #dbe2ee; border-radius: 50%; }
.loading-orbit span { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.loading-orbit span:nth-child(1) { top: -3px; left: 11px; animation: orbit 1.3s var(--ease) infinite; }
.loading-orbit span:nth-child(2) { right: 0; bottom: 5px; opacity: .6; animation: orbit 1.3s .15s var(--ease) infinite; }
.loading-orbit span:nth-child(3) { bottom: 0; left: 3px; opacity: .35; animation: orbit 1.3s .3s var(--ease) infinite; }
@keyframes orbit { 50% { transform: scale(1.5); } }
.loading-title { margin: 0; font-size: 14px; font-weight: 800; }
.loading-label { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

/* =========================================================================
   错误提示
   ========================================================================= */
.viewer-error {
    position: absolute;
    z-index: 300;
    top: 22px;
    left: 50%;
    width: min(680px, calc(100% - 32px));
    padding: 13px 16px;
    border: 1px solid #f2b8ad;
    border-radius: var(--radius-sm);
    color: #8a1f11;
    background: #fff4f1;
    box-shadow: 0 10px 24px rgb(138 31 17 / 10%);
    transform: translateX(-50%);
    line-height: 1.5;
}

/* =========================================================================
   签批抽屉 — 右侧纵向单列，可收起为把手，不遮挡文档
   ========================================================================= */
.sign-drawer {
    position: fixed;
    z-index: 170;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: none;
    align-items: stretch;
    /* 展开时整条向左滑出；收起时仅露出把手 */
}
.sign-drawer.is-on { display: flex; }
.sign-drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    align-self: center;
    margin-left: -1px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    box-shadow: -4px 4px 12px rgb(57 70 88 / 18%);
    cursor: pointer;
    transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.sign-drawer-toggle:hover { background: var(--accent-deep); transform: scale(1.06); }
.sign-drawer-toggle:active { transform: scale(.96); }
.sign-drawer-toggle .toggle-icon {
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M15 18l-6-6 6-6'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform var(--dur-2) var(--ease);
}
/* 展开时把手箭头转向右 */
.sign-drawer:not(.collapsed) .toggle-icon { transform: rotate(180deg); }

/* 抽屉主体：纵向单列，宽度固定；收起时通过负 margin 滑出视口 */
.sign-drawer-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 76px;
    padding: 12px 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: var(--chrome);
    box-shadow: -8px 8px 24px rgb(57 70 88 / 14%);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    /* 收起：向右滑出视口；展开：滑回。transition 处理动画。 */
    transition: margin-right var(--dur-3) var(--ease-out);
}
.sign-drawer.collapsed .sign-drawer-body { margin-right: calc(-1 * (76px + 1px)); }
.sign-drawer:not(.collapsed) .sign-drawer-body { margin-right: 0; }

/* 分隔线（横向，分组之间） */
.sign-drawer-body .drawer-divider {
    width: 70%;
    height: 1px;
    margin: 2px 0;
    background: var(--line);
    flex-shrink: 0;
}

/* 工具按钮（纵向堆叠，全宽） */
#sign-type .btn-wrap {
    display: flex;
    width: 100%;
    min-height: 46px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
#sign-type .btn-wrap:hover { color: var(--ink); background: var(--hover-bg); }
#sign-type .btn-wrap:active { transform: scale(.96); }
#sign-type .btn-wrap.active { color: #fff; background: var(--accent); box-shadow: 0 4px 10px var(--accent-glow); }
#sign-type .btn-icon { width: 22px; height: 22px; background-size: contain; background-position: center; background-repeat: no-repeat; }
#sign-type .btn-text { font-size: 10px; line-height: 1; }
#sign-type #pen .btn-icon { background-image: url('../../static/icon/pen.png'); }
#sign-type #pen.active .btn-icon { background-image: url('../../static/icon/pen-active.png'); }
#sign-type #hand .btn-icon { background-image: url('../../static/icon/hand.png'); }
#sign-type #hand.active .btn-icon { background-image: url('../../static/icon/hand-active.png'); }
#sign-type #eraser .btn-icon { background-image: url('../../static/icon/eraser.png'); }
#sign-type #eraser.active .btn-icon { background-image: url('../../static/icon/eraser-active.png'); }

/* 撤销/重做图标（内联 SVG） */
#sign-type .btn-wrap.disabled { opacity: .38; pointer-events: none; }
#sign-type .btn-wrap.disabled .btn-icon { filter: grayscale(100%); }
#sign-type .undo-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23526174' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 14L4 9l5-5'/><path d='M4 9h11a5 5 0 015 5v0a5 5 0 01-5 5H9'/></svg>");
}
#sign-type .redo-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23526174' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M15 14l5-5-5-5'/><path d='M20 9H9a5 5 0 00-5 5v0a5 5 0 005 5h6'/></svg>");
}
#sign-type .btn-wrap.active .undo-icon,
#sign-type .btn-wrap.active .redo-icon {
    filter: brightness(0) invert(1);
}

/* 颜色选择器：纵向单列 */
#sign-type .color-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}
#sign-type .color-group .swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgb(255 255 255 / 80%);
    background: var(--swatch-color, #999);
    box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgb(0 0 0 / 10%);
    cursor: pointer;
    transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
#sign-type .color-group .swatch:hover { transform: scale(1.12); }
#sign-type .color-group .swatch.active {
    box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgb(255 255 255 / 90%), 0 2px 6px rgb(0 0 0 / 15%);
    transform: scale(1.05);
}

/* 线宽选择器：纵向单列 */
#sign-type .width-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}
#sign-type .width-group .btn-wrap { min-height: 40px; }
#sign-type .width-preview {
    display: block;
    width: 22px;
    border-radius: 999px;
    background: currentColor;
}
#sign-type .width-thin { height: 2px; }
#sign-type .width-medium { height: 4px; }
#sign-type .width-thick { height: 7px; }
#sign-type .width-group .btn-wrap.active .width-preview { background: #fff; }

/* =========================================================================
   橡皮擦光圈（修复布局泄漏 bug：默认隐藏、固定定位、不占布局）
   尺寸匹配 SignaturePad 橡皮擦宽度（20px * 2 = 40px 视觉光圈）
   ========================================================================= */
#touch-circle {
    position: fixed;
    top: 0;
    left: 0;
    display: none;
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: rgb(70 105 216 / 8%);
    box-shadow: 0 0 0 1px rgb(255 255 255 / 70%), 0 2px 8px rgb(70 105 216 / 18%);
    pointer-events: none;
    z-index: 9999;
}

/* =========================================================================
   通用状态
   ========================================================================= */
.disabled { opacity: .36; pointer-events: none; }
.disabled .btn-icon { filter: grayscale(100%); }

/* 统一 focus-visible（覆盖所有交互元素） */
#toolbar .btn-wrap:focus-visible,
#sign-type .btn-wrap:focus-visible,
.dialog button:focus-visible,
.floating-upload-button:focus-visible,
.dialog.zoom .dialog-content .item:focus-visible,
.dialog.eye .dialog-content .warp:focus-visible {
    outline: 3px solid var(--accent-glow);
    outline-offset: 2px;
}

/* 忙碌态（保存按钮、预览按钮） */
.test-source-actions .btn[aria-busy="true"],
#save_pdf[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}
.test-source-actions .btn[aria-busy="true"]::after,
#save_pdf[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: page-spinner .7s linear infinite;
}
#save_pdf[aria-busy="true"]::after { border-color: currentColor; border-right-color: transparent; }

/* =========================================================================
   响应式（< 768px）- 从 responsive.css 合并，去除冲突声明
   ========================================================================= */
@media (max-width: 767px) {
    /* Header 折叠：隐藏文档名与副标题，brand mark + upload 并排 */
    .document-context { display: none; }
    .brand-caption { display: none; }
    .brand-lockup { min-width: 0; }
    .floating-upload-button {
        min-height: 34px;
        padding: 0 12px;
        font-size: 12px;
    }
    .floating-upload-button .upload-icon { width: 16px; height: 16px; font-size: 15px; }

    /* 工具栏图标按钮化 */
    #toolbar { height: 56px; padding: 6px 8px; }
    #toolbar .btn-text { display: none; }
    #toolbar .btn-wrap {
        width: auto;
        min-width: 44px;
        height: 44px;
        flex: 1 1 0;
        border-radius: var(--radius-sm);
        gap: 0;
    }
    #toolbar .btn-icon { width: 20px; height: 20px; }

    /* 页码指示器收紧 */
    .page-num {
        top: calc(var(--header-height) + 10px);
        padding: 6px 11px;
        font-size: 11px;
    }
    .page-num .current-page { font-size: 14px; }

    /* 签批抽屉紧凑：收窄主体宽度，按钮/色块更小 */
    .sign-drawer-body { width: 64px; padding: 10px 6px; gap: 5px; }
    .sign-drawer.collapsed .sign-drawer-body { margin-right: calc(-1 * (64px + 1px)); }
    #sign-type .btn-wrap { min-height: 40px; }
    #sign-type .btn-icon { width: 18px; height: 18px; }
    #sign-type .btn-text { font-size: 9px; }
    #sign-type .color-group { gap: 5px; }
    #sign-type .color-group .swatch { width: 22px; height: 22px; }
    #sign-type .width-group { gap: 5px; }
    #sign-type .width-preview { width: 18px; }

    /* 对话框适配 */
    .dialog { width: min(500px, calc(100vw - 24px)); border-radius: var(--radius-lg); }
    .dialog .dialog-title { padding: 18px 20px 13px; font-size: 16px; }
    .dialog .dialog-content { padding: 18px 20px; }
    .dialog .btn-wrap { padding: 11px 16px 14px; }

    .dialog.zoom .dialog-content { gap: 10px; }
    .dialog.zoom .dialog-content .item { min-height: 104px; padding: 14px; }
    .dialog.zoom .dialog-content .title { font-size: 14px; }
    .dialog.zoom .dialog-content .description { font-size: 11px; }

    .dialog.eye .dialog-content { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
    .dialog.eye .dialog-content .color-wrap { width: 44px; height: 44px; }

    .dialog.goto .dialog-content .page-info { font-size: 12px; }
    .dialog.goto .dialog-content .btn { font-size: 12px; min-height: 36px; padding: 0 10px; }
    .dialog.goto .dialog-content .goto-num { width: 58px; min-height: 36px; }
    .dialog.goto .dialog-content .goto-num-label { font-size: 12px; }

    .dialog.test-source input[type="text"],
    .dialog.test-source input[type="file"] { min-height: 40px; padding: 8px 10px; }
    .test-source-actions .btn { min-height: 40px; }

    /* 查看器容器底部留白匹配矮工具栏 */
    #viewer-container { padding-bottom: 90px; }
}

/* =========================================================================
   动效降级
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
