/* ================= 🎨 双主题配色系统 (CSS 变量) ================= */
:root {
    --bg-base: #f5f6fa;
    --bg-surface: #ecedf3;
    --card: #ffffff;
    --card-hover: #f0f1f5;
    --primary: #6c63ff;
    --primary-hover: #5b52ee;
    --primary-soft: #ebe9ff;
    --accent: #0ea5e9;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #d97706;
    --text-main: #111827;
    --text-sub: #4b5563;
    --text-dim: #6b7280;
    --border: #d1d5db;
    --divider: #e5e7eb;
    --listbox-bg: #f9fafb;
    --btn-text: #ffffff;
    --trust-bg: #ebe9ff;
    --trust-text: #6c63ff;
}

[data-theme='dark'] {
    --bg-base: #0f1117;
    --bg-surface: #181a20;
    --card: #1e2028;
    --card-hover: #282a34;
    --primary: #7b73ff;
    --primary-hover: #635bee;
    --primary-soft: #1f1b3d;
    --accent: #38bdf8;
    --success: #34d399;
    --success-hover: #10b981;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --warning: #fbbf24;
    --text-main: #e8eaed;
    --text-sub: #9aa0ac;
    --text-dim: #6b7280;
    --border: #2c2f3a;
    --divider: #24272f;
    --listbox-bg: #14161c;
    --btn-text: #0f1117;
    --trust-bg: #1f1b3d;
    --trust-text: #e8eaed;
}

/* ================= 🛠️ 全局样式 ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition:
        background-color 0.3s,
        color 0.3s;
}

.trust-banner {
    background-color: var(--trust-bg);
    color: var(--trust-text);
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
    z-index: 20;
}

.app-body {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
    width: 100%;
}

input[type='file'] {
    display: none;
}
input[type='text'],
input[type='number'],
select {
    background-color: var(--card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 6px 10px;
    outline: none;
}
input[type='text']:focus,
input[type='number']:focus,
select:focus {
    border-color: var(--primary);
}
input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type='number'] {
    -moz-appearance: textfield;
}

/* ================= 🌟 侧边栏 ================= */
.sidebar {
    width: 210px;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    padding: 24px 0;
    transition: background-color 0.3s;
    flex-shrink: 0;
    overflow-y: auto;
}

.logo-area {
    padding: 0 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.logo-icon {
    color: var(--primary);
    font-size: 24px;
    line-height: 1;
}
.logo-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-main);
    line-height: 1;
    margin-top: 2px;
}

.divider {
    height: 1px;
    background-color: var(--divider);
    margin: 0 14px 14px 14px;
}

.nav-label {
    font-size: 11px;
    color: var(--text-dim);
    padding: 0 22px;
    margin-bottom: 8px;
    margin-top: 8px;
}
.nav-btn {
    text-decoration: none;
    background: transparent;
    border: none;
    color: var(--text-sub);
    padding: 12px 22px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    width: calc(100% - 24px);
    margin: 0 auto 4px auto;
    border-radius: 10px;
    display: block;
    transition: all 0.2s;
}
.nav-btn:hover {
    background-color: var(--card);
    color: var(--text-main);
}
.nav-btn.active {
    background-color: var(--primary-soft);
    color: var(--primary);
    font-weight: bold;
}

.spacer {
    flex-grow: 1;
    min-height: 20px;
}
.theme-toggle {
    margin: 0 14px;
    padding: 10px;
    border-radius: 10px;
    background-color: var(--card);
    border: 1px solid var(--border);
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.theme-toggle:hover {
    background-color: var(--card-hover);
}
.mobile-menu-toggle {
    display: none;
}
.mobile-nav-overlay {
    display: none;
}
.mobile-drawer {
    display: none;
}

/* ================= 📚 内容区 ================= */
.main-content {
    flex-grow: 1;
    padding: 24px 32px 0 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.page-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.header h1 {
    font-size: 24px;
}
.badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 8px;
    background-color: var(--card);
    color: var(--accent);
}
.badge-warning {
    color: var(--warning);
}
.badge-primary {
    background-color: var(--primary-soft);
    color: var(--primary);
}

.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}
.card-stretch {
    flex-grow: 1;
}
.privacy-card {
    gap: 10px;
    line-height: 1.8;
}
.privacy-card h2 {
    font-size: 18px;
}
.privacy-card p,
.privacy-list {
    color: var(--text-sub);
    font-size: 14px;
}
.privacy-list {
    padding-left: 20px;
}
.privacy-list li + li {
    margin-top: 6px;
}
.action-card {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.settings-panel {
    min-width: 0;
}
.global-toolbar {
    min-width: 0;
}

/* 通用布局/文本工具类 */
.nav-label-spaced {
    margin-top: 12px;
}
.layout-toggle-inline {
    margin-left: auto;
    font-size: 12px;
}
.u-flex-grow {
    flex-grow: 1;
}
.u-toolbar-count {
    flex-grow: 1;
    text-align: right;
    color: var(--text-dim);
    font-size: 12px;
}
.u-hint-text {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 12px;
}
.u-hint-center {
    text-align: center;
}
.u-hint-top-tight {
    margin-top: -16px;
    margin-bottom: 20px;
}
.u-surface-panel {
    background-color: var(--bg-surface);
    border-radius: 12px;
    padding: 10px 20px;
}
.u-surface-panel-lg {
    background-color: var(--bg-surface);
    border-radius: 12px;
    padding: 16px 20px;
}
.u-panel-title {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.u-status-text {
    color: var(--text-sub);
    font-size: 13px;
}
.u-w-full {
    width: 100%;
}
.u-w-80 {
    width: 80px;
}
.u-w-200 {
    width: 200px;
}
.u-select-wide {
    width: 100%;
    max-width: 400px;
}
.u-mode-vertical {
    align-items: flex-start;
    flex-direction: column;
}
.u-label-strong {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
}
.u-row-gap-8 {
    display: flex;
    gap: 8px;
}
.u-row-gap-12 {
    display: flex;
    gap: 12px;
}
.u-row-gap-16 {
    display: flex;
    gap: 16px;
}
.u-row-gap-16-wrap {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.u-items-center {
    align-items: center;
}
.u-items-end {
    align-items: flex-end;
}
.u-justify-between {
    justify-content: space-between;
}
.u-text-center {
    text-align: center;
}
.u-danger-outline {
    color: var(--danger);
    border-color: var(--danger);
}
.u-flex-1-min-120 {
    flex: 1;
    min-width: 120px;
}
.u-flex-1-min-150 {
    flex: 1;
    min-width: 150px;
}
.u-flex-2-min-200 {
    flex: 2;
    min-width: 200px;
}
.u-mt-8 {
    margin-top: 8px;
}
.u-mt-20 {
    margin-top: 20px;
}
.u-mb-24 {
    margin-bottom: 24px;
}
.u-flex-1 {
    flex: 1;
}
.u-btn-block {
    margin-top: 8px;
    width: 100%;
}
.u-zoom-label-40 {
    font-size: 13px;
    font-weight: bold;
    width: 40px;
    text-align: center;
}
.u-zoom-label-50 {
    font-size: 14px;
    font-weight: bold;
    width: 50px;
    text-align: center;
}
.u-btn-zoom-compact {
    padding: 2px 8px;
    font-weight: bold;
    border: none;
}
.u-btn-fit-compact {
    padding: 2px 8px;
    font-size: 12px;
    border: none;
}
.u-btn-zoom {
    padding: 4px 12px;
    font-weight: bold;
}
.u-btn-fit {
    padding: 4px 12px;
    font-size: 12px;
}
.u-position-relative {
    position: relative;
}
.u-flex-wrap {
    flex-wrap: wrap;
}
.u-text-dim {
    color: var(--text-dim);
}
.u-text-13-bold {
    font-size: 13px;
    font-weight: bold;
}

/* 编辑页预览弹窗 */
.edit-preview-modal-content {
    max-width: 900px;
    flex-direction: column;
    align-items: center;
    max-height: 95vh;
}
.edit-preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.edit-preview-title {
    font-size: 18px;
}
.edit-preview-zoom-box {
    background: var(--bg-surface);
    padding: 4px 12px;
    border-radius: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
}
.edit-preview-canvas-wrap {
    box-shadow: none;
    border: none;
    height: 60vh;
    width: 100%;
    background: #e5e7eb;
    overflow: hidden;
    cursor: grab;
}
.edit-preview-zoom-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center;
    transition: transform 0.1s ease-out;
    width: 100%;
    height: 100%;
}
.edit-preview-rotate-container {
    position: relative;
    transition: transform 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}
.edit-preview-canvas {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: none;
}
.edit-preview-mask {
    display: none;
    font-size: 32px;
    width: 100%;
    height: 100%;
}
.edit-preview-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* 水印页专用 */
.wm-tip-highlight {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 12px;
    font-weight: bold;
}
.wm-page-grid-offset {
    margin-top: 20px;
}
.wm-modal-canvas-wrap {
    box-shadow: none;
    border: none;
    height: 100%;
    cursor: grab;
    background: #e5e7eb;
}
.wm-modal-zoom-container {
    position: relative;
    transform-origin: center;
    transition: transform 0.1s ease-out;
    display: flex;
    justify-content: center;
    align-items: center;
}
.wm-modal-canvas {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.wm-modal-overlay-canvas {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
}
.wm-modal-floating-tools {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 16px;
    align-items: center;
    z-index: 10;
}
.wm-modal-title {
    margin-bottom: 16px;
    font-size: 18px;
}
.wm-modal-actions-row {
    display: flex;
    gap: 8px;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}
.btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-primary {
    background-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}
.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-sub);
}
.btn-outline:hover {
    background-color: var(--card-hover);
    color: var(--text-main);
}
.btn-danger {
    background-color: var(--danger);
    color: #fff;
    padding: 8px 16px;
    font-size: 13px;
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-run {
    background-color: var(--success);
    color: var(--btn-text);
    font-size: 15px;
    font-weight: bold;
    padding: 12px 24px;
}
.btn-run:hover {
    background-color: var(--success-hover);
}
.btn-run-danger {
    background-color: var(--danger);
    color: #fff;
}
.btn-run-danger:hover {
    background-color: var(--danger-hover);
}
.btn-run:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 首页卡片 */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.tool-card {
    text-decoration: none;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}
.tool-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.tool-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-card p {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.5;
    margin: 0;
}
.tool-icon {
    font-size: 24px;
}
.layout-toggle {
    white-space: nowrap;
    flex-shrink: 0;
    display: none;
}

/* 列表 & 拆分表单样式 */
.file-list-wrapper {
    background-color: var(--listbox-bg);
    border-radius: 10px;
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    position: relative;
    min-height: 200px;
    display: block;
}
.file-list {
    list-style: none;
    min-height: 100%;
    padding-bottom: 10px;
}
.file-item {
    padding: 12px 16px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    font-size: 13px;
}
.file-item .remove-icon {
    color: var(--danger);
    cursor: pointer;
    font-weight: bold;
    padding: 6px 12px;
    font-size: 16px;
    margin-right: -8px;
}
.empty-tip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
}
.file-list:not(:empty) + .empty-tip {
    display: none;
}

.split-file-btn {
    background-color: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}
.split-file-btn:hover {
    background-color: var(--card-hover);
    border-color: var(--primary);
}

/* --- 新增：加载完成后的文件卡片 --- */
.file-loaded-card {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 24px 16px;
    background-color: var(--card);
    color: var(--success);
    position: relative;
    margin-bottom: 20px;
    font-size: 15px;
}
.file-loaded-card .file-name {
    font-weight: bold;
}
.trash-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--danger);
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.trash-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
}
.trash-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.mode-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
}
.mode-row:last-child {
    border-bottom: none;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    width: 140px;
}
.mode-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: auto;
}

/* --- 新增：全景预览网格与工具 --- */
.pdf-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    align-content: start;
    grid-auto-rows: max-content;
    gap: 16px;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border-radius: 12px;
    max-height: 55vh;
    overflow-y: auto;
}
.pdf-page-item {
    position: relative;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.pdf-page-canvas-wrapper {
    position: relative;
    width: 100%;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--divider);
    border-radius: 4px;
    flex-shrink: 0;
    min-height: 50px;
}
.pdf-page-canvas {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}
.pdf-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}
.page-btn {
    border: 1px solid var(--border);
    background: var(--card);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-sub);
    flex-grow: 1;
    text-align: center;
    transition: background 0.2s;
}
.page-btn:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}
.page-btn-danger {
    color: var(--danger);
}
.page-number-label {
    font-size: 12px;
    margin-top: 4px;
    width: 100%;
    text-align: center;
    color: var(--text-dim);
}
.page-deleted-mask {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    color: var(--danger);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    z-index: 10;
    pointer-events: none;
    border: 2px dashed var(--danger);
    box-sizing: border-box;
}

.custom-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--warning);
    color: #fff;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    z-index: 6;
    display: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- 新增：Modal 弹窗 --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 760px;
    display: flex;
    gap: 24px;
    max-height: 90vh;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.modal-left {
    flex: 1;
    background: var(--bg-surface);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    overflow: hidden;
    position: relative;
}
.modal-right {
    width: 280px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* 始终放在通用 display 工具类之后，避免被覆盖 */
.u-hidden {
    display: none;
}

/* 页脚 */
.footer {
    padding: 24px 0;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    border-top: 1px solid var(--divider);
    margin-top: auto;
}
.footer a {
    color: var(--text-sub);
    text-decoration: none;
    margin: 0 8px;
}
.footer a:hover {
    color: var(--primary);
}
.icp-line {
    margin-top: 6px;
    font-size: 12px;
}
.icp-line a {
    color: var(--text-dim);
    text-decoration: none;
}

@media (max-width: 900px) {
    .sidebar {
        width: 188px;
    }
    .main-content {
        padding: 22px 24px 0 24px;
    }
    .pdf-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
        gap: 12px;
        padding: 12px;
    }
}

/* ================= 📱 移动端适配 ================= */
@media (max-width: 768px) {
    body {
        min-height: 100dvh;
        height: auto;
        overflow: auto;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .trust-banner {
        padding: 7px 12px;
        font-size: 12px;
        line-height: 1.45;
    }

    .app-body {
        flex-direction: column;
        flex-grow: 0;
        min-height: 0;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        height: 62px;
        padding: 12px 14px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
        z-index: 110;
        overflow: visible;
        position: sticky;
        top: 0;
    }

    .logo-area {
        order: 1;
        margin: 0;
        padding: 0;
        flex: 1 1 auto;
        min-width: 0;
    }
    .logo-title {
        font-size: 16px;
        white-space: nowrap;
    }
    .logo-icon {
        font-size: 22px;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--card);
        color: var(--text-main);
        cursor: pointer;
        font-size: 22px;
        line-height: 1;
        flex: 0 0 auto;
        order: 0;
        z-index: 114;
    }

    .mobile-drawer-close {
        position: absolute;
        top: 18px;
        right: 18px;
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: var(--text-dim);
        cursor: pointer;
        font-size: 24px;
        font-weight: 300;
        line-height: 1;
        padding: 0;
        z-index: 1;
    }

    .theme-toggle {
        order: 20;
        display: block;
        margin: 10px 18px 0;
        padding: 11px 12px;
        font-size: 13px;
        width: calc(100% - 36px);
        height: auto;
        white-space: nowrap;
        flex: 0 0 auto;
    }
    .divider,
    .nav-label,
    .spacer {
        display: none;
    }

    .mobile-drawer {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        width: min(72vw, 280px);
        height: 100dvh;
        background: var(--bg-surface);
        border-right: 1px solid var(--border);
        box-shadow: 14px 0 34px rgba(0, 0, 0, 0.18);
        z-index: 113;
        transform: translateX(-100%);
        transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
        flex-direction: column;
        padding: 76px 18px 24px;
        gap: 6px;
        overflow-y: auto;
    }

    .mobile-drawer.open {
        transform: translateX(0);
    }

    .mobile-drawer-title {
        font-size: 18px;
        font-weight: bold;
        color: var(--text-main);
        margin-bottom: 12px;
        line-height: 1;
    }

    .mobile-drawer .nav-btn,
    .mobile-drawer .theme-toggle {
        position: static;
        left: auto;
        top: auto;
        width: 100%;
        margin: 0 0 4px;
        padding: 12px 14px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 10px;
        background: var(--card);
        color: var(--text-sub);
        text-align: left;
        white-space: nowrap;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
        transform: none;
        opacity: 1;
        pointer-events: auto;
        transition:
            background-color 0.2s,
            color 0.2s;
        z-index: auto;
    }

    .mobile-drawer .theme-toggle {
        margin-top: auto;
        border-style: dashed;
        color: var(--text-main);
        text-align: center;
    }

    .nav-btn::before {
        display: inline-block;
        width: 22px;
        margin-right: 8px;
        text-align: center;
    }

    #nav-home::before {
        content: '⌂';
    }
    #nav-merge::before {
        content: '＋';
    }
    #nav-split::before {
        content: '⌁';
    }
    #nav-edit::before {
        content: '↻';
    }
    #nav-pdf2img::before {
        content: '▧';
    }
    #nav-img2pdf::before {
        content: '▤';
    }
    #nav-watermark::before {
        content: '💧';
    }

    .mobile-nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.42);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 112;
    }

    .mobile-nav-overlay.is-visible {
        opacity: 1;
        pointer-events: auto;
        touch-action: none;
    }

    .main-content {
        padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
        overflow: visible;
        flex-grow: 0;
        min-height: 0;
    }

    .page-view {
        flex-grow: 0;
        min-height: 0;
    }

    .header {
        margin-bottom: 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header h1 {
        font-size: 20px;
    }
    .badge {
        font-size: 10px;
    }
    .card {
        padding: 14px;
        margin-bottom: 14px;
        border-radius: 12px;
    }
    .card-stretch {
        flex-grow: 0;
    }

    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .tool-card {
        min-height: 128px;
        padding: 14px;
        border-radius: 12px;
        overflow: hidden;
    }

    .tool-card h3 {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        font-size: 14px;
        line-height: 1.35;
        margin-bottom: 6px;
    }

    .tool-card p {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.45;
    }

    .tool-icon {
        font-size: 22px;
        line-height: 1;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .toolbar .btn {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
        padding: 9px 10px;
    }
    #mergeFileCount,
    #imgCount {
        width: 100%;
        flex-basis: 100%;
        text-align: left;
        margin-top: 4px;
    }

    .btn {
        min-height: 38px;
        padding: 9px 12px;
    }
    .btn-run {
        width: 100%;
        min-height: 44px;
        padding: 11px 16px;
    }

    .split-file-btn {
        padding: 22px 14px;
        margin-bottom: 14px;
        border-radius: 10px;
        line-height: 1.5;
    }

    .file-loaded-card {
        justify-content: flex-start;
        padding: 16px 50px 16px 14px;
        min-height: 58px;
        text-align: left;
    }

    .file-loaded-card .file-name {
        display: block;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .trash-btn {
        right: 4px;
        padding: 10px;
    }

    .file-list-wrapper {
        min-height: 240px;
        max-height: 48dvh;
        padding: 8px;
    }

    .file-item {
        gap: 8px;
        padding: 10px 10px 10px 12px;
        min-height: 48px;
        align-items: center;
    }

    .file-item span:first-child,
    .file-item-content span {
        min-width: 0;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .file-item .remove-icon {
        flex: 0 0 auto;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 10px;
        margin-right: -4px;
    }

    .file-item-content {
        min-width: 0;
        width: auto !important;
        flex: 1 1 auto;
    }

    .settings-panel {
        padding: 12px !important;
        border-radius: 10px !important;
    }

    .mode-row {
        flex-wrap: wrap;
        align-items: flex-start !important;
        gap: 8px;
        padding: 12px 0;
    }
    .radio-label {
        width: 100%;
    }
    .mode-desc {
        margin-left: 0;
        width: 100%;
        margin-top: 4px;
    }
    input[type='number'],
    select {
        flex: 1 1 0;
        min-width: 0;
    }
    input[type='text'] {
        width: 100% !important;
        margin-top: 4px;
    }

    .wm-tip {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .watermark-settings > div {
        gap: 8px !important;
    }

    .watermark-settings .setting-group {
        min-width: 0 !important;
    }

    .watermark-settings > div:nth-child(2) .setting-group:first-child {
        flex: 1 1 100% !important;
    }

    .watermark-settings > div:nth-child(2) .setting-group:not(:first-child) {
        flex: 1 1 0 !important;
    }

    .watermark-settings > div:nth-child(3) .setting-group {
        flex: 1 1 calc(50% - 5px) !important;
    }

    .action-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
        text-align: center;
    }

    .action-card span {
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .global-toolbar {
        padding: 12px !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .global-toolbar > div {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px !important;
    }

    .pdf-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
        gap: 10px;
        padding: 10px;
        max-height: none;
        border-radius: 10px;
    }

    .pdf-page-item {
        padding: 6px;
        border-radius: 7px;
    }

    .pdf-page-actions {
        gap: 5px;
    }

    .page-btn {
        padding: 6px 7px;
        min-height: 30px;
        font-size: 11px;
    }

    .modal-overlay {
        align-items: stretch;
        padding: 10px;
    }

    .modal-content {
        flex-direction: column;
        overflow-y: auto;
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 20px);
        padding: 14px;
        gap: 14px;
        border-radius: 12px;
    }
    .modal-right {
        width: 100%;
    }
    .modal-left {
        min-height: 260px;
        max-height: 48dvh;
        padding: 10px;
    }

    .modal-right-scroll {
        max-height: 34dvh;
    }

    .modal-right-actions {
        background: var(--card);
        position: sticky;
        bottom: 0;
    }

    #previewModal .modal-content {
        align-items: stretch;
        max-height: calc(100dvh - 20px);
    }

    #previewModal .modal-content > div:first-child {
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 0;
    }

    #previewModal .modal-content > div:first-child > div {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
    }

    #previewModalCanvasWrap {
        height: 55dvh;
        min-height: 300px;
    }

    .layout-toggle {
        display: inline-block;
    }

    #homeGrid {
        grid-template-columns: 1fr;
        max-width: 600px;
    }
    #homeGrid.compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        max-width: none;
    }
    #homeGrid.compact .tool-card {
        padding: 28px 20px;
        min-height: auto;
    }
    #homeGrid.compact .tool-card h3 {
        font-size: 17px;
        margin-bottom: 0;
        justify-content: center;
        text-align: center;
    }
    #homeGrid.compact .tool-card .tool-icon {
        font-size: 28px;
    }
    #homeGrid.compact .tool-card p {
        display: none;
    }

    .hide-on-mobile {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .trust-banner {
        text-align: left;
    }

    .sidebar {
        padding: 10px 12px 9px;
    }

    .logo-title {
        max-width: 96px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .theme-toggle,
    .nav-btn {
        font-size: 12px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .main-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .header h1 {
        font-size: 19px;
    }
    .card {
        padding: 12px;
    }
    .tool-card {
        padding: 14px;
    }

    .toolbar .btn {
        flex-basis: 100%;
    }

    .file-list-wrapper {
        min-height: 220px;
        max-height: 44dvh;
    }

    .pdf-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .page-btn {
        flex-basis: 100%;
    }

    .modal-overlay {
        padding: 6px;
    }

    .modal-content {
        max-height: calc(100dvh - 12px);
        padding: 12px;
    }

    .modal-left {
        min-height: 220px;
        max-height: 42dvh;
    }

    .modal-right-actions > div {
        flex-direction: column;
    }

    #previewModalCanvasWrap {
        min-height: 260px;
        height: 50dvh;
    }
}

@media (max-width: 400px) {
    .home-grid {
        grid-template-columns: 1fr;
    }

    .tool-card h3 {
        flex-direction: row;
        align-items: center;
    }

    .tool-card {
        min-height: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== img-to-pdf 页面组件 (I-16) ===== */
.img-preview {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}
.file-item-content {
    display: flex;
    align-items: center;
    width: calc(100% - 30px);
}
.file-item-content span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== watermark 页面组件 (I-17) ===== */
.setting-group {
    margin-bottom: 12px;
}
.setting-group label {
    display: block;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text-main);
}
.wm-canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}
.modal-right {
    overflow-y: visible;
}
.modal-right-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.modal-right-actions {
    flex-shrink: 0;
    border-top: 1px solid var(--divider);
    padding-top: 16px;
}
