 /* 加载遮罩样式 */
    .loading-mask {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.8);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99999;
      transition: opacity 0.3s ease;
    }

    .loading-mask.hidden {
      opacity: 0;
      pointer-events: none;
    }

    .loading-content {
      text-align: center;
      color: white;
    }

    .loading-spinner {
      width: 50px;
      height: 50px;
      margin: 0 auto 20px;
      border: 4px solid rgba(255, 255, 255, 0.3);
      border-top: 4px solid #4fc1ad;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    .loading-text {
      font-size: 18px;
      font-weight: 500;
      letter-spacing: 1px;
      animation: pulse 1.5s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }.file-list__body {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    :root {
      color-scheme: dark;
      font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", sans-serif;
      --bg-gradient: radial-gradient(circle at 20% 20%, #1e202a 0%, #141620 55%, #0c0d12 100%);
      --panel-bg: rgba(28, 30, 40, 0.9);
      --panel-border: rgba(255, 255, 255, 0.06);
      --primary: #6a8bff;
      --secondary: #4fc1ad;
      --text-main: rgba(239, 241, 250, 0.95);
      --text-subtle: rgba(191, 196, 216, 0.72);
      --divider: rgba(255, 255, 255, 0.08);
      --shadow: 0 18px 42px rgba(0, 3, 16, 0.68);
    }

    *,
    *::before,
    *::after {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      height: 100vh;
      background: var(--bg-gradient);
      color: var(--text-main);
      display: flex;
      flex-direction: column;
      align-items: stretch;
    }

    .bg-glow {
      display: none;
    }

    /* 页面头部样式 */
    .page-header {
      text-align: center;
      padding: 40px 5vw 20px;
      margin-bottom: 10px;
    }

    .page-title {
      font-size: clamp(2.2rem, 4.5vw, 3rem);
      font-weight: 700;
      letter-spacing: 0.8px;
      margin: 0 0 16px 0;
      background: linear-gradient(135deg, #7c97ff, #5f80ff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .page-description {
      font-size: 1.1rem;
      color: var(--text-subtle);
      margin: 0;
      max-width: 600px;
      margin-left: auto;
      margin-right: auto;
      line-height: 1.6;
    }

    /* 布局头部样式 - 一行显示 */
    .layout-header {
      display: flex;
      align-items: center;
      gap: 20px;
      padding: 16px 20px;
      background: rgba(40, 43, 56, 0.7);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      margin-bottom: 20px;
    }

    .layout-title {
      font-size: 1.5rem;
      font-weight: 700;
      margin: 0;
      background: linear-gradient(135deg, #7c97ff, #5f80ff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .layout-desc {
      font-size: 1rem;
      color: var(--text-subtle);
      margin: 0;
    }

    .hero {
      padding: 48px 5vw 28px;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: flex-end;
      position: relative;
      z-index: 1;
    }

    .hero__content h1 {
      font-size: clamp(2.1rem, 4.1vw, 2.8rem);
      font-weight: 700;
      letter-spacing: 0.6px;
      margin: 0;
    }

    .hero__content p {
      margin: 12px 0 0;
      font-size: 1.02rem;
      color: var(--text-subtle);
      max-width: 520px;
    }

    .hero__actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .chip {
      background: rgba(48, 50, 65, 0.6);
      color: var(--text-main);
      border: 1px solid var(--divider);
      border-radius: 999px;
      padding: 7px 16px;
      font-weight: 500;
      font-size: 0.9rem;
      cursor: pointer;
      transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    }

    .chip:hover {
      transform: translateY(-1px);
      background: rgba(62, 66, 82, 0.78);
      border-color: rgba(255, 255, 255, 0.18);
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 22px;
      padding: 0 5vw 16px;
      position: relative;
      z-index: 1;
    }

    .panel {
      border-radius: 20px;
      padding: 22px;
      background: var(--panel-bg);
      border: 1px solid var(--panel-border);
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      gap: 16px;
      min-height: 290px;
    }

    .panel__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .panel__header h2 {
      font-size: 1.32rem;
      margin: 0;
    }

    .panel__subtitle {
      margin: 0;
      color: var(--text-subtle);
      font-size: 0.96rem;
    }

    .panel__footer {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-top: auto;
    }

    .tag {
      font-size: 0.8rem;
      font-weight: 600;
      padding: 5px 12px;
      border-radius: 999px;
      letter-spacing: 0.4px;
      text-transform: uppercase;
      color: var(--text-subtle);
      background: rgba(56, 60, 77, 0.55);
      border: 1px solid var(--divider);
    }

    .tag--sunset {
      color: var(--primary);
    }

    .tag--aqua {
      color: var(--secondary);
    }

    .tag--ghost {
      color: var(--text-subtle);
    }

    .dropzone {
      border: 1px dashed rgba(255, 255, 255, 0.1);
      border-radius: 16px;
      padding: 22px 16px;
      position: relative;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.2s ease, background 0.2s ease;
    }

    .dropzone:hover {
      border-color: rgba(255, 255, 255, 0.22);
      background: rgba(54, 58, 74, 0.5);
    }

    .dropzone input {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      cursor: pointer;
    }

    .dropzone__content {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      color: var(--text-subtle);
    }

    .dropzone__icon {
      font-size: 1.4rem;
    }

    .form {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .form--inline {
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .form__label {
      font-weight: 600;
      font-size: 0.92rem;
      color: var(--text-main);
    }

    .form__input {
      border: none;
      border-radius: 12px;
      padding: 11px 12px;
      font-size: 0.96rem;
      background: rgba(56, 60, 77, 0.6);
      color: var(--text-main);
      outline: 2px solid transparent;
      transition: outline 0.2s ease, background 0.2s ease;
    }

    .form__input:focus {
      outline: 2px solid rgba(106, 139, 255, 0.55);
      background: rgba(60, 66, 86, 0.7);
    }

    .slider {
      display: flex;
      align-items: center;
      gap: 12px;
      flex: 1;
    }

    .slider input[type="range"] {
      flex: 1;
      accent-color: var(--primary);
    }

    .slider__value {
      min-width: 44px;
      text-align: right;
      font-weight: 600;
      color: var(--text-main);
    }

    .file-list-wrapper {
      background: rgba(40, 43, 56, 0.7);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      padding: 14px 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      flex: 1;
      overflow: hidden;
    }

    .file-list-wrapper--compact {
      padding: 12px 14px;
    }

    .file-list--single {
      max-height: unset;
    }

    .file-list__header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: var(--text-subtle);
      font-size: 0.9rem;
    }

    .link-btn {
      border: none;
      background: none;
      color: var(--text-subtle);
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      padding: 0;
      transition: color 0.2s ease;
    }

    .link-btn:hover {
      color: var(--text-main);
    }

    .file-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 10px;
      height: 190px;
      overflow-y: auto;
    }

    .file-list__item {
      display: flex;
      align-items: center;
      gap: 12px;
      background: rgba(52, 56, 70, 0.65);
      border: 1px solid rgba(255, 255, 255, 0.04);
      border-radius: 12px;
      padding: 10px 12px;
    }

    .file-list__name {
      flex: 1;
      color: var(--text-main);
      font-size: 0.88rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .file-list__meta {
      font-size: 0.8rem;
      color: var(--text-subtle);
    }

    .file-list__controls {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .file-list--images .file-list__item {
      align-items: flex-start;
    }

    .icon-btn {
      border: none;
      background: rgba(70, 74, 90, 0.8);
      color: var(--text-main);
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: grid;
      place-items: center;
      cursor: pointer;
      transition: background 0.2s ease, transform 0.2s ease;
    }

    .icon-btn:hover {
      background: rgba(92, 96, 114, 0.9);
      transform: translateY(-1px);
    }

    .icon-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
      transform: none;
    }

    .file-list__index {
      width: 26px;
      height: 26px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.05);
      display: grid;
      place-items: center;
      font-size: 0.78rem;
      color: var(--text-subtle);
    }

    .file-list__empty {
      text-align: center;
      padding: 16px 0;
      border: 1px dashed var(--divider);
      border-radius: 12px;
      color: var(--text-subtle);
      font-size: 0.88rem;
    }

    .panel--secondary {
      border-color: rgba(79, 193, 173, 0.25);
    }

    .panel--ghost {
      border-color: rgba(255, 255, 255, 0.04);
    }

    .btn {
      border: none;
      border-radius: 14px;
      padding: 12px 20px;
      font-size: 0.98rem;
      font-weight: 600;
      letter-spacing: 0.5px;
      color: rgba(12, 15, 26, 0.92);
      cursor: pointer;
      transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    }

    .btn--primary {
      background: linear-gradient(135deg, #7c97ff, #5f80ff);
      box-shadow: 0 12px 24px rgba(95, 128, 255, 0.28);
    }

    .btn--secondary {
      background: linear-gradient(135deg, #63d2c0, #47b3a3);
      box-shadow: 0 12px 24px rgba(71, 179, 163, 0.28);
    }

    .btn--ghost {
      background: linear-gradient(135deg, #c084fc, #a855f7);
      box-shadow: 0 12px 24px rgba(168, 85, 247, 0.28);
    }

    .btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
      background: linear-gradient(135deg, #6b7280, #4b5563) !important;
    }

    .btn:not(:disabled):hover {
      transform: translateY(-1px);
      box-shadow: 0 16px 28px rgba(8, 10, 18, 0.32);
    }

    .status {
      font-size: 0.9rem;
      color: var(--text-subtle);
      min-height: 1.2em;
    }

    .status--success {
      color: #66d3c3;
    }

    .status--error {
      color: #ff7b7b;
    }

    .tips {
      margin: 0;
      padding-left: 18px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      color: var(--text-subtle);
    }

    .footer {
      margin-top: auto;
      padding: 24px 5vw 16px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: var(--text-subtle);
      font-size: 0.92rem;
      position: relative;
      z-index: 1;
    }

    .footer__links {
      display: flex;
      gap: 20px;
    }

    .footer__links a {
      color: var(--text-subtle);
      text-decoration: none;
      font-weight: 600;
      transition: color 0.2s ease;
    }

    .footer__links a:hover {
      color: var(--text-main);
    }

    /* PDF合并内容布局 */
    .merge-content-layout {
      display: grid;
      grid-template-columns: minmax(300px, 1fr) 2fr minmax(320px, 1fr);
      gap: 24px;
      height: calc(100vh - 220px);
      align-items: stretch;
      min-height: 700px;
    }

    /* 布局设置样式 */
    .layout-settings {
      background: rgba(40, 43, 56, 0.7);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      padding: 16px;
      height: 100%;
      min-height: 0;
    }

    /* 文件操作区域样式 */
    .file-operations {
      display: flex;
      flex-direction: column;
      gap: 20px;
      height: 100%;
      min-height: 0;
      overflow: hidden;
    }

    .file-operations .dropzone {
      margin-bottom: 0;
    }

    .file-operations .file-list-wrapper {
      margin-bottom: 20px;
    }

    .file-operations .merge-actions {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
    }

    .file-operations .btn {
      width: 100%;
      justify-content: center;
    }

    .file-operations .btn-icon {
      margin-right: 8px;
    }

    .layout-settings h3 {
      font-size: 1.1rem;
      margin: 0 0 16px 0;
      color: var(--text-main);
    }

    .preset-modes {
      margin-bottom: 20px;
      padding-bottom: 16px;
      border-bottom: 1px solid var(--divider);
    }

    .preset-modes .setting-item {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .preset-modes label {
      font-weight: 600;
      color: var(--text-main);
      flex-shrink: 0;
      margin-right: 8px;
    }

    .preset-modes select {
      padding: 8px 12px;
      border: 1px solid var(--divider);
      border-radius: 8px;
      background: var(--panel-bg);
      color: var(--text-main);
      font-size: 0.9rem;
      min-width: 150px;
    }

    .layout-grid {
      display: flex;
      flex-direction: column;
      gap: 16px;
      margin-bottom: 16px;
    }

    .setting-item {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .setting-item label {
      font-size: 0.9rem;
      color: var(--text-subtle);
      font-weight: 500;
    }

    .setting-item select,
    .setting-item input[type="number"] {
      padding: 8px 12px;
      border: 1px solid var(--divider);
      border-radius: 8px;
      background: var(--panel-bg);
      color: var(--text-main);
      font-size: 0.9rem;
      transition: border-color 0.2s ease, background 0.2s ease;
    }

    .setting-item select:focus,
    .setting-item input[type="number"]:focus {
      outline: none;
      border-color: var(--primary);
      background: rgba(60, 66, 86, 0.7);
    }

    .grid-inputs {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .grid-inputs input {
      width: 60px;
      text-align: center;
    }

    .grid-inputs span {
      color: var(--text-subtle);
      font-weight: 600;
    }

    .custom-grid {
      grid-column: span 2;
    }

    /* 间距设置样式 */
    .setting-item:has(#item-margin) {
      border-top: 1px solid var(--divider);
      padding-top: 12px;
      margin-top: 8px;
    }

    /* 分割线设置样式 */
    .grid-line-controls {
      grid-column: span 2;
    }

    .grid-line-settings {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-top: 8px;
    }

    .grid-line-input {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .grid-line-input label {
      font-size: 0.85rem;
      color: var(--text-subtle);
      font-weight: 500;
    }

    .grid-line-input input[type="color"] {
      width: 100%;
      height: 36px;
      border: 1px solid var(--divider);
      border-radius: 6px;
      background: var(--panel-bg);
      cursor: pointer;
      padding: 2px;
    }

    .grid-line-input input[type="number"] {
      padding: 8px 10px;
      border: 1px solid var(--divider);
      border-radius: 6px;
      background: var(--panel-bg);
      color: var(--text-main);
      font-size: 0.85rem;
    }

    /* 布局预览样式 */
    .layout-preview {
      background: rgba(40, 43, 56, 0.7);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      padding: 16px;
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
    }

    .layout-preview h4 {
      font-size: 1rem;
      margin: 0 0 12px 0;
      color: var(--text-main);
    }

    .layout-preview .preview-container {
      border: 1px solid var(--divider);
      border-radius: 12px;
      background: rgba(28, 30, 40, 0.8);
      padding: 8px;
      flex: 1;
      overflow: auto;
      min-height: 0;
      max-height: 100%;
    }

    .preview-pages {
      display: flex;
      flex-direction: column;
      gap: 12px;
      align-items: center;
      width: 100%;
      height: 100%;
    }

    .preview-page {
      border: 2px solid var(--divider);
      border-radius: 8px;
      background: var(--panel-bg);
      display: grid;
      gap: 2px;
      padding: 4px;
      position: relative;
    }

    .preview-page.landscape {
      width: 100%;
      max-width: 550px;
      aspect-ratio: 1.414; /* A4横版比例 */
    }

    .preview-page.portrait {
      width: 100%;
      max-width: 400px;
      aspect-ratio: 0.707; /* A4竖版比例 */
    }

    .preview-page::before {
      content: attr(data-page-number);
      position: absolute;
      top: -8px;
      right: 8px;
      background: var(--primary);
      color: var(--text-main);
      font-size: 0.7rem;
      padding: 2px 6px;
      border-radius: 4px;
      font-weight: 600;
    }

    .preview-item {
      background: rgba(106, 139, 255, 0.1);
      border: 1px solid rgba(106, 139, 255, 0.3);
      border-radius: 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.7rem;
      color: var(--text-subtle);
      overflow: hidden;
      position: relative;
    }



    .preview-empty {
      background: rgba(255, 255, 255, 0.02);
      border: 1px dashed var(--divider);
      color: var(--text-subtle);
      opacity: 0.5;
    }

    .preview-empty::after {
      content: '';
    }

    /* 预览图片样式 */
    .preview-item img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      background: white;
      border-radius: 1px;
    }

    /* 预览错误状态 */
    .preview-error {
      background: rgba(220, 53, 69, 0.1);
      border: 1px solid rgba(220, 53, 69, 0.3);
      color: var(--text-subtle);
    }

    .preview-error::after {
      content: '';
    }

    /* 使用小贴士样式 */
    .tips-section {
      margin-top: 20px;
      background: rgba(40, 43, 56, 0.7);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      padding: 16px;
    }

    .tips-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
    }

    .tips-header h4 {
      font-size: 1rem;
      margin: 0;
      color: var(--text-main);
    }

    .tips-section .tips {
      margin: 0;
      padding-left: 18px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      color: var(--text-subtle);
      font-size: 0.88rem;
    }

    .tips-section .tips li {
      line-height: 1.4;
    }

    /* 日志显示区域样式 */
    .log-display {
      position: fixed;
      top: 20px;
      right: 20px;
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      color: white;
      padding: 12px 16px;
      border-radius: 12px;
      font-size: 0.9rem;
      font-weight: 500;
      max-width: 400px;
      word-wrap: break-word;
      box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
      z-index: 9999;
      opacity: 0;
      transform: translateY(-10px);
      transition: all 0.3s ease;
      border: 1px solid rgba(255, 255, 255, 0.1);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
    }

    .log-display.show {
      opacity: 1;
      transform: translateY(0);
    }

    .log-display .log-content {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .log-display .log-item {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      line-height: 1.4;
    }

    .log-display .log-timestamp {
      color: rgba(255, 255, 255, 0.7);
      font-size: 0.75rem;
      font-family: monospace;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .log-display .log-message {
      flex: 1;
    }

    .log-display .log-close {
      position: absolute;
      top: 8px;
      right: 8px;
      background: rgba(255, 255, 255, 0.2);
      border: none;
      color: white;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      transition: background 0.2s ease;
    }

    .log-display .log-close:hover {
      background: rgba(255, 255, 255, 0.3);
    }

    /* 小屏幕适配 */
    @media (max-width: 1200px) {
      .merge-content-layout {
        grid-template-columns: 1fr;
        gap: 20px;
        height: auto;
        min-height: 600px;
      }

      .layout-settings {
        height: auto;
        min-height: 0;
      }

      .layout-preview {
        height: auto;
        min-height: 400px;
      }

      .file-operations {
        height: auto;
        min-height: 0;
      }
    }

    /* 移动端适配 */
    @media (max-width: 768px) {
      .page-header {
        padding: 30px 7vw 20px;
        margin-bottom: 10px;
      }

      .page-title {
        font-size: 1.8rem;
        margin-bottom: 12px;
      }

      .page-description {
        font-size: 1rem;
        padding: 0 10px;
      }

      /* 布局头部移动端 - 改为垂直显示 */
      .layout-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
      }

      .layout-title {
        font-size: 1.2rem;
      }

      .layout-desc {
        font-size: 0.9rem;
      }

      .hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 22px;
        padding: 40px 7vw 22px;
      }

      .grid {
        padding: 0 7vw 16px;
      }

      .panel {
        padding: 20px;
      }

      .merge-content-layout {
        grid-template-columns: 1fr;
        gap: 20px;
        height: auto;
        min-height: 0;
      }

      .layout-settings {
        order: 1;
      }

      .layout-preview {
        order: 2;
      }

      .file-operations {
        order: 3;
      }

      .layout-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
      }

      .preset-modes .setting-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
      }

      .preset-modes select {
        min-width: 100%;
      }

      .footer {
        flex-direction: column;
        gap: 14px;
        text-align: center;
      }

      .log-display {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 0.85rem;
      }
    }

/* 合并后操作按钮 */
#post-merge-actions {
  display: flex;
  gap: 10px;
}

/* 隐藏自定义网格输入框 */
#custom-grid {
  display: none;
}