.ruler-tip { font-size: 12px; color: #8a8f9a; margin: -6px 0 4px; }

.dpi-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.dpi-preset { padding: 4px 10px; font-size: 12px; }
.dpi-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-detect { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.auto-dpi-tag {
    display: none;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 1px 7px;
    border-radius: 999px;
    vertical-align: middle;
}

.calib-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed var(--border, #d9dce3);
    border-radius: 8px;
    background: #fafbfc;
}
.calib-title { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.ref-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ref-presets .btn { padding: 4px 8px; font-size: 12px; }
.ref-block-wrap { margin-top: 8px; }
.ref-block-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.ref-block {
    width: 100px; height: 22px;
    background: repeating-linear-gradient(45deg, #34d399, #34d399 8px, #22c55e 8px, #22c55e 16px);
    border-radius: 4px;
}
.ref-block::after { content: ""; display: block; width: 100%; height: 4px; background: #f59e0b; border-radius: 0 0 4px 4px; }

.ruler-read { font-size: 14px; font-weight: 700; color: var(--primary, #2563eb); }

.ruler-area {
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    min-height: 200px;
}
.ruler-scroll {
    overflow-x: auto;               /* only horizontal long rulers scroll */
    padding: 28px 12px 12px;
}
.ruler-area .ruler-scroll { overflow-y: visible; }
.ruler {
    position: relative;
    height: 54px;
    min-width: 120px;
    background: repeating-linear-gradient(to bottom, #fff5e6 0 24px, #ffe8c2 24px 27px);
    border: 1px solid #d8a13c;
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.ruler-ticks { position: absolute; inset: 0; }
.tick { position: absolute; width: 1px; background: #2c2c2c; }
.tick-min { height: 7px; top: 0; }
.tick-mid { height: 11px; top: 0; width: 1.4px; background: #444; }
.tick-unit { height: 16px; top: 0; width: 1.6px; background: #111; }
.tick-num {
    position: absolute; top: 18px;
    font-size: 11px; color: #222;
    white-space: nowrap;
}

/* 纵向尺子：刻度沿 Y 轴排布 */
.ruler.vertical {
    height: 0;                     /* height set by JS */
    width: 54px;
    background: repeating-linear-gradient(to right, #fff5e6 0 24px, #ffe8c2 24px 27px);
}
.ruler.vertical .tick { top: auto; left: 0; width: auto; }
.ruler.vertical .tick-min { width: 7px; height: 1px; }
.ruler.vertical .tick-mid { width: 11px; height: 1.4px; background: #444; }
.ruler.vertical .tick-unit { width: 16px; height: 1.6px; background: #111; }
.ruler.vertical .tick-num {
    top: auto; left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* 游标（横向竖线 / 纵向横线） */
.ruler-cursor { position: absolute; width: 0; cursor: ew-resize; touch-action: none; }
.ruler:not(.vertical) .ruler-cursor { top: -8px; bottom: -8px; }
.ruler.vertical .ruler-cursor { top: 0; left: -8px; right: -8px; height: 0; cursor: ns-resize; }
.ruler:not(.vertical) .cursor-edge {
    position: absolute; top: -6px; bottom: -6px; left: 0;
    width: 2px; background: #ef4444;
    box-shadow: 0 0 0 1px rgba(239,68,68,.25);
}
.ruler.vertical .cursor-edge {
    position: absolute; left: -6px; right: -6px; top: 0;
    height: 2px; background: #ef4444;
    box-shadow: 0 0 0 1px rgba(239,68,68,.25);
}
.ruler:not(.vertical) .cursor-edge::before {
    content: ""; position: absolute; top: -8px; left: -6px;
    border: 6px solid transparent; border-top-color: #ef4444;
}
.ruler:not(.vertical) .cursor-edge::after {
    content: ""; position: absolute; bottom: -8px; left: -6px;
    border: 6px solid transparent; border-bottom-color: #ef4444;
}
.ruler.vertical .cursor-edge::before {
    content: ""; position: absolute; left: -8px; bottom: -6px;
    border: 6px solid transparent; border-left-color: #ef4444;
}
.ruler.vertical .cursor-edge::after {
    content: ""; position: absolute; right: -8px; bottom: -6px;
    border: 6px solid transparent; border-right-color: #ef4444;
}
.ruler-cursor-label {
    position: absolute; z-index: 3;
    background: #ef4444; color: #fff;
    font-size: 12px; font-weight: 700;
    padding: 2px 8px; border-radius: 4px;
    white-space: nowrap;
}
.ruler:not(.vertical) .ruler-cursor-label { top: -26px; left: 50%; transform: translateX(-50%); }
.ruler.vertical .ruler-cursor-label { top: 50%; left: -8px; transform: translate(-100%, -50%); }

.ruler-tip-line { text-align: center; color: #6b7280; font-size: 12px; margin-top: 8px; }

.print-help ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.9; color: #374151; }
.print-help .ph-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }

.print-preview-info { text-align: center; color: #374151; font-size: 14px; padding: 10px; line-height: 1.8; }
.print-preview-info .icon { font-size: 44px; margin-bottom: 6px; }

/* A4 实时预览（屏幕显示，结构与打印页一致） */
.a4-preview { margin-top: 18px; }
.a4-preview-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; color: #374151; }
.a4-page {
    width: 100%;
    aspect-ratio: 210 / 297;
    max-width: 280px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #c7ccd6;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    padding: 12px 6px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    overflow: hidden;
}
.a4-preview-note { font-size: 10px; color: #9aa0aa; margin-top: auto; }
.print-ruler {
    position: relative;
    background: #fff;
    border-bottom: 1px solid #444;
}
.print-ruler .ptick { position: absolute; top: 0; background: #111; }

/* ---------- A4 print area (hidden on screen, true-size on print) ---------- */
#printArea { display: none; }

@media print {
    @page { size: A4 portrait; margin: 5mm; }
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    body > *:not(#printArea) { display: none !important; }
    #printArea { display: block !important; }
    #printRulerList { padding-top: 2mm; }
    .print-note { text-align: center; font-size: 3.5mm; color: #333; margin-top: 3mm; padding-top: 2mm; border-top: 0.2mm solid #999; }
    .print-ruler {
        position: relative;
        height: 14mm;
        margin-bottom: 10mm;
        background: #fff;
        border-bottom: 0.4mm solid #111;
        box-sizing: content-box;
    }
    .ptick { position: absolute; top: 0; width: 0.2mm; background: #111; }
    .p-min { height: 3mm; }
    .p-mid { height: 6mm; width: 0.25mm; }
    .p-cm { height: 10mm; width: 0.3mm; }
    .p-num { position: absolute; top: 11mm; font-size: 4mm; color: #111; line-height: 1; }
    .a4-preview, .a4-page, .a4-preview-title, .print-preview-info { display: none !important; }
}

