/* ============================================================
 * 网页端样式（与小程序同一套设计语言）
 *
 * 色板
 *   背景 #f4f6fa   卡片 #fff   描边 #eaedf3
 *   墨色 #11151c   正文 #3d4754  次要 #6f7b8a  弱 #8a97a8
 *   品牌 #1e4fd8   选中 #141a24  浅底 #eef3ff  警示 #b76b00
 *
 * 约定
 *   - 选中态用墨黑，可点行动用品牌蓝
 *   - 重要提示用 .hint-panel（浅蓝底 + 左侧色条），普通说明用 #6f7b8a
 *   - 不依赖 flex gap（Chrome 84 以下 / Safari 14.1 以下不支持），间距用 margin 或 grid gap
 * ============================================================ */

:root {
    --brand: #1e4fd8;
    --brand-2: #2f63f2;
    --brand-soft: #eef3ff;
    --brand-line: #d9e4ff;
    --ink: #11151c;
    --ink-strong: #141a24;
    --text: #3d4754;
    --text-2: #6f7b8a;
    --text-3: #8a97a8;
    --line: #eaedf3;
    --line-soft: #f3f5f9;
    --bg: #f4f6fa;
    --warn: #b76b00;
    --ok: #12a05c;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 6px 20px rgba(17, 21, 28, .05);
    --shadow-lg: 0 16px 40px rgba(17, 21, 28, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶部品牌区 ---------------- */

.topbar {
    padding: 30px 24px 22px;
    background: linear-gradient(180deg, #eef2fa 0%, #f4f6fa 100%);
}

.brand {
    max-width: 1272px;
    margin: 0 auto;
}

.eyebrow {
    display: flex;
    align-items: center;
    color: #5b6b86;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
}

.eyebrow::before {
    content: '';
    width: 6px;
    height: 6px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--brand);
}

.topbar h1 {
    margin: 12px 0 0;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.4px;
    color: var(--ink);
}

.subtitle {
    margin: 8px 0 0;
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 6px;
}

/* 隐私承诺：与小程序首页保持一致的胶囊徽标（小锁用纯 CSS 画，不引资源） */
.subtitle strong {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px 4px 10px;
    background: var(--brand-soft, #eef3ff);
    border: 1px solid #d3e0fd;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #1b3fa0;
}

.badge-lock {
    position: relative;
    width: 10px;
    height: 8px;
    margin: 4px 6px 0 0;
    background: var(--brand);
    border-radius: 2px;
}

.badge-lock::before {
    content: '';
    position: absolute;
    left: 1.5px;
    top: -4.5px;
    box-sizing: border-box;
    width: 7px;
    height: 7px;
    border: 1.5px solid var(--brand);
    border-bottom-color: transparent;
    border-radius: 4px 4px 0 0;
}

.subtitle-sep {
    color: #c2cad6;
}

.hero-chips {
    display: flex;
    flex-wrap: wrap;
    margin-top: 14px;
}

.chip {
    margin: 0 8px 8px 0;
    padding: 4px 11px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #e4e9f2;
    color: #46536a;
    font-size: 12px;
    line-height: 1.6;
}

.chip.ghost {
    background: transparent;
    border-style: dashed;
    color: var(--text-3);
}

/* ---------------- 布局 ---------------- */

.layout {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 24px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 24px 48px;
    align-items: start;
}

.panel {
    display: flex;
    flex-direction: column;
}

/* 用 margin 代替 flex gap：Chrome 84 以下 / Safari 14.1 以下内核不支持 gap */
.panel > * + * {
    margin-top: 16px;
}

/* ---------------- 卡片 ---------------- */

.card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .2px;
    color: var(--ink);
}

.card-sub {
    margin-top: 6px;
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.55;
}

.card-head > .link-btn {
    flex: none;
    margin-left: 12px;
}

/* ---------------- 文件选择 ---------------- */

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 26px 18px 22px;
    border: 1.5px dashed #cfd8e6;
    border-radius: 14px;
    background: #fbfcfe;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dropzone.has-file {
    border-style: solid;
    border-color: var(--brand-line);
    background: #f5f8ff;
}

.dz-icon {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    background: linear-gradient(150deg, #f4f7ff 0%, #e3ecff 100%);
    border: 1px solid var(--brand-line);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CSS 画的文档图标：比 emoji 更克制，也和各处提示的视觉一致 */
.doc-glyph {
    position: relative;
    display: block;
    width: 20px;
    height: 26px;
    background: #ffffff;
    border: 1.5px solid var(--brand);
    border-radius: 4px;
}

.doc-glyph::before,
.doc-glyph::after {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    height: 1.5px;
    border-radius: 1px;
    background: #a9c1f8;
}

.doc-glyph::before {
    top: 7px;
}

.doc-glyph::after {
    top: 12px;
}

.doc-glyph-lg {
    width: 30px;
    height: 38px;
    border-width: 2px;
    border-radius: 6px;
}

.doc-glyph-lg::before {
    top: 11px;
    height: 2px;
}

.doc-glyph-lg::after {
    top: 19px;
    height: 2px;
}

.dz-title {
    margin-top: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    word-break: break-all;
}

.dz-desc {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-3);
}

/* ---------------- 醒目提示 ---------------- */

.hint-panel {
    display: flex;
    flex-direction: column;
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--brand-soft);
    border-left: 3px solid var(--brand);
    border-radius: 4px 12px 12px 4px;
}

.hint-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #1b3fa0;
}

.hint-text {
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.6;
    color: #23406e;
}

/* ---------------- 预设 ---------------- */

.preset-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.preset-row .btn.preset {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 预设为奇数个时，最后一个占满整行，避免右侧留半格空白 */
.preset-row .btn.preset:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* ---------------- 按钮 ---------------- */

.btn {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.btn:hover {
    border-color: var(--brand-line);
    color: var(--brand);
    background: #fbfcff;
}

.btn.preset {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    font-size: 13.5px;
    font-weight: 500;
}

.btn.preset.active {
    background: var(--ink-strong);
    border-color: var(--ink-strong);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(17, 21, 28, .18);
}

.btn.preset.active:hover {
    background: var(--ink-strong);
    border-color: var(--ink-strong);
    color: #ffffff;
}

.btn.primary {
    background: linear-gradient(135deg, var(--brand-2) 0%, var(--brand) 100%);
    border-color: transparent;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 10px 24px rgba(30, 79, 216, .22);
}

.btn.primary:hover {
    color: #ffffff;
    filter: brightness(1.05);
}

.btn.primary:disabled {
    opacity: .5;
    box-shadow: none;
    filter: none;
    cursor: not-allowed;
}

.btn.ghost {
    background: var(--line-soft);
    border-color: #e6eaf1;
    color: var(--text);
}

.btn.ghost:hover {
    color: var(--text);
    border-color: #d8dfe9;
    background: #eef1f6;
}

/* ---------------- 表单 ---------------- */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.field > * + * {
    margin-top: 6px;
}

.field > span {
    font-size: 12px;
    letter-spacing: .2px;
    color: var(--text-2);
}

.field input,
.field select {
    width: 100%;
    height: 38px;
    padding: 0 11px;
    border: 1px solid #edf0f6;
    border-radius: 10px;
    background: #f7f9fc;
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.field input:hover,
.field select:hover {
    border-color: #dde3ec;
}

.field input:focus,
.field select:focus {
    border-color: var(--brand);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(30, 79, 216, .12);
}

.field input:disabled,
.field select:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ---------------- 页签 ---------------- */

.tabs {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.tab {
    padding: 6px 13px;
    margin: 0 8px 8px 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #f7f9fc;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.tab:hover {
    border-color: var(--brand-line);
    color: var(--brand);
}

.tab.active {
    background: var(--ink-strong);
    border-color: var(--ink-strong);
    color: #ffffff;
    font-weight: 600;
}

.style-body {
    display: flex;
    flex-direction: column;
}

.style-body > * + * {
    margin-top: 10px;
}

.group-label {
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-3);
}

/* ---------------- 底部操作区 ---------------- */

/* 桌面端做成单行工具条：粘在视口底部时只占 ~66px，少遮内容 */
.panel-actions {
    position: -webkit-sticky;
    position: sticky;
    bottom: 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 12px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 -6px 24px rgba(17, 21, 28, .08);
}

/* 支持毛玻璃的浏览器上做成半透明工具条，压在内容上时更轻 */
@supports (backdrop-filter: blur(8px)) {
    .panel-actions {
        background: rgba(255, 255, 255, .88);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }
}

.panel-actions > * + * {
    margin-top: 0;
    margin-left: 10px;
}

.panel-actions .btn {
    flex: 1 1 0;
    width: auto;
    height: 42px;
    font-size: 14px;
}

.panel-actions .btn.primary {
    flex: 1.4 1 0;
}

/* ---------------- 预览 ---------------- */

.preview {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
}

.preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 提示文案变长后要能换行：原来是单行 flex，长文案把左侧「共 N 页」挤成「共…」。
       改成 flex-wrap，空间不够时提示整段换到第二行，状态文字始终完整可读。 */
    flex-wrap: wrap;
    row-gap: 4px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-2);
    background: #ffffff;
}

#statusText {
    flex: 0 0 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-bar .hint {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 12px;
    color: var(--text-3);
    line-height: 1.5;
    /* 窄屏（手机）时提示单独占一行，不与状态文字抢宽度 */
    text-align: right;
}

.pages-wrap {
    flex: 1;
    padding: 28px;
    background: #eef1f6;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: auto;
    min-height: 400px;
    -webkit-overflow-scrolling: touch;
}

.pages-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* zoom / transform 缩放时以顶部中心为基准 */
    transform-origin: top center;
}

.pages-inner > .pv-page + .pv-page {
    margin-top: 20px;
}

.empty {
    margin: auto;
    text-align: center;
    color: var(--text-3);
    padding: 60px 20px;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 20px;
    background: linear-gradient(150deg, #ffffff 0%, #eef3ff 100%);
    border: 1px solid var(--brand-line);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty p {
    margin: 6px 0;
    font-size: 13px;
    color: var(--text-2);
}

.empty-sub {
    font-size: 12px;
    color: var(--text-3);
}

/* 版面（纸张） */
.pv-page {
    position: relative;
    background: #ffffff;
    box-shadow: 0 8px 28px rgba(17, 21, 28, .10);
    border-radius: 3px;
    flex: none;
}

/* 分栏容器：单栏时就是一个整宽容器，双栏时两个等高列并排 */
.pv-cols {
    display: flex;
    height: 100%;
    align-items: stretch;
}

.pv-body {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.pv-block {
    /* 老内核不认 flow-root，退回 block；flow-root 让子元素外边距参与高度计算 */
    display: block;
    display: flow-root;
    break-inside: avoid;
}

.pv-p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.pv-footer {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    color: #1f2329;
    line-height: 1.2;
    pointer-events: none;
}

.pv-tbl {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* 边框由 <td> 的内联样式给出（跟随文档的 tblBorders），这里不设默认边框 */
.pv-tbl td {
    padding: 3px 5px;
    vertical-align: top;
    word-break: break-word;
}

/* 通栏卷头：位于分栏容器上方，独占整幅宽 */
.pv-head {
    break-inside: avoid;
}

/* ---------------- 字体缺失提示 ---------------- */

.font-note {
    margin-top: 14px;
    padding: 12px 14px;
    background: #fff8ec;
    border-left: 3px solid #d99a2b;
    border-radius: 4px 12px 12px 4px;
    color: #7a5200;
    font-size: 12.5px;
    line-height: 1.6;
}

.font-note[hidden] {
    display: none;
}

/* ---------------- 复选框行 / 折叠 ---------------- */

.check-row {
    display: flex;
    align-items: flex-start;
    margin-top: 12px;
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.6;
    cursor: pointer;
}

.check-row:hover {
    color: var(--ink);
}

.check-row input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 2px 9px 0 0;
    accent-color: var(--brand);
}

.check-row .warn {
    color: var(--warn);
    font-weight: 600;
    /* 「需左边距 ≥ 4cm」不许被拆成两行 */
    white-space: nowrap;
}

.link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--brand);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

.collapse-hint {
    margin: 0;
    color: var(--text-2);
    font-size: 12.5px;
    line-height: 1.6;
}

.collapse-hint[hidden] {
    display: none;
}

#stylePanel[hidden] {
    display: none;
}

/* ---------------- 环境提示条 ---------------- */

.env-tip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 48px);
    max-width: 1272px;
    margin: 14px auto 0;
    padding: 12px 14px;
    background: #fff8ec;
    border-left: 3px solid #d99a2b;
    border-radius: 4px 12px 12px 4px;
    color: #7a5200;
    font-size: 13px;
    line-height: 1.5;
}

.env-tip[hidden] {
    display: none;
}

.env-tip-close {
    flex: none;
    margin-left: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    line-height: 22px;
    border: none;
    background: transparent;
    color: #7a5200;
    font-size: 18px;
    cursor: pointer;
}

/* ---------------- 浏览器兜底 ---------------- */

.browser-tip {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.browser-tip[hidden] {
    display: none;
}

.browser-tip-inner {
    max-width: 520px;
    padding: 36px 30px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.browser-tip-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    line-height: 48px;
    border-radius: 50%;
    background: #fdecea;
    color: #d54941;
    font-size: 22px;
    font-weight: 700;
}

.browser-tip-inner h2 {
    margin: 0 0 10px;
    font-size: 19px;
    color: var(--ink);
}

.browser-tip-inner p {
    margin: 6px 0;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.7;
}

.browser-tip-sub {
    color: var(--text-3) !important;
    font-size: 12px !important;
}

/* ---------------- Toast ---------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 36px;
    transform: translateX(-50%) translateY(14px);
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(17, 21, 28, .92);
    color: #ffffff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    max-width: 80vw;
    box-shadow: 0 10px 30px rgba(17, 21, 28, .22);
    z-index: 99;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: #d54941;
}

/* ---------------- 窄屏 / 平板 ---------------- */

@media (max-width: 1080px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 18px 16px 40px;
    }

    .panel-actions {
        position: static;
        bottom: auto;
    }

    .pages-wrap {
        padding: 16px;
    }

    .topbar h1 {
        font-size: 27px;
    }
}

/* ---------------- 手机（国产浏览器、微信内置浏览器） ---------------- */

@media (max-width: 640px) {
    .topbar {
        padding: 20px 16px 16px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 12.5px;
    }

    .chip {
        font-size: 11.5px;
        padding: 3px 10px;
    }

    .env-tip {
        width: calc(100% - 24px);
        margin: 12px auto 0;
        font-size: 12px;
    }

    .layout {
        padding: 12px 12px 32px;
        gap: 12px;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
    }

    .card-title {
        font-size: 14.5px;
    }

    .dz-icon {
        width: 46px;
        height: 46px;
    }

    .btn.preset {
        height: 46px;
    }

    .pages-wrap {
        padding: 10px;
        min-height: 320px;
    }

    .preview {
        min-height: 50vh;
    }

    .preview-bar {
        padding: 10px 12px;
        font-size: 11.5px;
    }

    .preview-bar .hint {
        display: none;
    }

    /* iOS 上输入框字号小于 16px 会触发页面自动放大 */
    .field input,
    .field select {
        font-size: 16px;
        height: 42px;
    }

    .btn {
        font-size: 14px;
        padding: 10px 12px;
    }

    .panel-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-actions > * + * {
        margin-left: 0;
        margin-top: 8px;
    }

    .panel-actions .btn {
        width: 100%;
        height: 48px;
        font-size: 15px;
    }

    .tab {
        font-size: 13px;
        padding: 7px 13px;
    }

    .preset-row .btn.preset {
        min-width: 0;
        margin-right: 0;
    }
}

/* 横屏小高度设备（手机横屏看预览） */
@media (max-height: 520px) and (max-width: 1080px) {
    .topbar {
        padding: 12px 16px 10px;
    }

    .pages-wrap {
        min-height: 240px;
    }
}
