.option-chip {
        transition: all 0.2s ease;
        border: 1px solid #e5e7eb;
        background: #f9fafb;
        color: #374151;
    }

    .option-chip:hover {
        border-color: #93c5fd;
        background: #eff6ff;
    }

    .option-chip.active {
        background: #3b82f6;
        color: #fff;
        border-color: #3b82f6;
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
    }

    .font-select {
        background: transparent;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        padding: 8px 12px;
        font-size: 14px;
        cursor: pointer;
        transition: border-color 0.3s ease;
    }

    .font-select:focus {
        outline: none;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    .slider {
        -webkit-appearance: none;
        height: 6px;
        border-radius: 3px;
        background: #e5e7eb;
        outline: none;
        width: 100%;
    }

    .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #3b82f6;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    .btn-primary {
        background: #3b82f6;
        transition: all 0.3s ease;
    }

    .btn-primary:hover {
        background: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
    }

    #previewWrap {
        background: transparent;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        min-width: 0;
    }

    #previewPaper {
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
        display: block;
        width: auto;
        height: auto;
        max-width: 100%;
        border: 1px solid #e5e7eb;
    }

    #paperStage {
        position: relative;
        display: block;
        flex-shrink: 0;
        min-width: 0;
        max-width: 100%;
        line-height: 0;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
        border: 1px solid #e5e7eb;
        background: #fff;
        overflow: visible;
    }

    #paperStage #previewPaper {
        box-shadow: none;
        border: none;
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        vertical-align: top;
    }

    .hf-modal-mask {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 80;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    /* 页面样式在 tailwind 之后，需显式压过 display:flex，否则 .hidden 无效 */
    .hf-modal-mask.hidden {
        display: none;
    }

    .hf-modal {
        width: min(720px, 100%);
        max-height: min(86vh, 820px);
        overflow: auto;
        background: #fff;
        border-radius: 20px;
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    }

    .hf-tip {
        background: #fff7ed;
        color: #c2410c;
        border: 1px solid #fed7aa;
        border-radius: 12px;
        padding: 10px 12px;
        font-size: 13px;
        line-height: 1.5;
    }

    .hf-item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        margin: 4px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #f9fafb;
        color: #374151;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.15s ease;
        user-select: none;
    }

    .hf-item:hover {
        border-color: #93c5fd;
        background: #eff6ff;
    }

    .hf-item.active {
        border-color: #3b82f6;
        background: #dbeafe;
        color: #1d4ed8;
        box-shadow: 0 0 0 1px #3b82f6 inset;
    }

    .hf-zone-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        margin-bottom: 8px;
    }

    .hf-zone-label {
        font-size: 12px;
        color: #6b7280;
        margin-left: 4px;
    }

    .hf-item.hf-zone {
        padding: 6px 14px;
        font-weight: 600;
    }

    .hf-item.hf-zone:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

    .hf-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 10px;
        margin: 2px;
        border-radius: 999px;
        background: #eff6ff;
        color: #1d4ed8;
        font-size: 12px;
        border: 1px solid #bfdbfe;
    }

    .hf-chip button {
        color: #64748b;
        line-height: 1;
    }

    .hf-chip button:hover {
        color: #ef4444;
    }

    #hfOverlay {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 2;
    }

    .hf-el {
        position: absolute;
        pointer-events: auto;
        cursor: move;
        color: transparent;
        font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
        white-space: nowrap;
        /* 文字由 canvas 绘制保证预览=导出；叠加层只负责选中/拖拽热区 */
        line-height: 1;
        padding: 0;
        border: 1px solid transparent;
        border-radius: 4px;
        user-select: none;
        -webkit-user-select: none;
        touch-action: none;
        transform-origin: left top;
        background: transparent;
        box-sizing: border-box;
    }

    .hf-el .hf-el-text {
        visibility: hidden;
        display: block;
        pointer-events: none;
    }

    .hf-el.selected {
        border-color: #3b82f6;
        box-shadow: 0 0 0 1px #3b82f6;
        background: rgba(59, 130, 246, 0.04);
    }

        .hf-el.locked {
            cursor: default;
        }

        .hf-el .hf-handle {
        position: absolute;
        width: 8px;
        height: 8px;
        background: #3b82f6;
        border: 1px solid #fff;
        display: none;
    }

    .hf-el.selected .hf-handle {
        display: block;
    }

    .hf-el .hf-handle.tl {
        left: -4px;
        top: -4px;
    }

    .hf-el .hf-handle.tr {
        right: -4px;
        top: -4px;
    }

    .hf-el .hf-handle.bl {
        left: -4px;
        bottom: -4px;
    }

    .hf-el .hf-handle.br {
        right: -4px;
        bottom: -4px;
    }

    #hfToolbar {
        position: absolute;
        display: none;
        z-index: 5;
        background: #3b82f6;
        color: #fff;
        border-radius: 10px;
        padding: 4px;
        gap: 2px;
        align-items: center;
        box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
        pointer-events: auto;
    }

    #hfToolbar.visible {
        display: inline-flex;
    }

    #hfToolbar button {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #fff;
    }

    #hfToolbar button:hover {
        background: rgba(255, 255, 255, 0.18);
    }

    @media print {
        @page {
            margin: 0;
        }

        html,
        body {
            margin: 0 !important;
            padding: 0 !important;
            background: #fff !important;
            height: auto !important;
            overflow: visible !important;
        }

        /*
         * 模板嵌套在 layout 内时，body * { display:none } 会把祖先一起藏掉，
         * 导致 #printArea 即使设为 block 也打不出来。打印区会挂到 body 下，
         * 只隐藏 body 的其它直接子节点。
         */
        body > *:not(#printArea) {
            display: none !important;
        }

        #printArea {
            display: block !important;
            visibility: visible !important;
            position: static !important;
            left: auto !important;
            top: auto !important;
            width: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
        }

        #printArea * {
            visibility: visible !important;
        }

        #printArea img {
            display: block !important;
            width: 100% !important;
            height: auto !important;
            max-width: 100% !important;
            max-height: 100vh !important;
            margin: 0 !important;
            padding: 0 !important;
            page-break-inside: avoid;
            break-inside: avoid;
            page-break-after: always;
            break-after: page;
        }

        #printArea img:last-child {
            page-break-after: auto;
            break-after: auto;
        }
    }
