.container-wide { max-width: 1280px; }
.pdf-editor { --editor-ink: #1e293b; --editor-line: #cbd5e1; color: var(--editor-ink); margin: 12px 0 32px; }
.pdf-editor button, .pdf-editor input, .pdf-editor select, .pdf-editor summary { font: inherit; }
.editor-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.editor-heading h1 { font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif; font-size: clamp(26px, 3vw, 34px); letter-spacing: -.035em; margin: 10px 0 8px; }
.editor-heading p { color: #475569; margin: 0; line-height: 1.5; }
.editor-back { font-size: 13px; color: #475569; }
.editor-history { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-jumps, .editor-return { display: none; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; align-items: start; }
.editor-workspace { min-width: 0; }
.editor-selection { border: 1px solid var(--editor-line); border-bottom: 0; border-radius: 12px 12px 0 0; background: #fff; padding: 18px; }
.selection-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.selection-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
#pageCount { font-family: ui-monospace, "SFMono-Regular", monospace; font-weight: 500; color: #475569; background: #edf2f7; border-radius: 5px; padding: 2px 7px; margin-left: 4px; }
.selection-count { font-size: 13px; color: #475569; }
.selection-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.range-selector { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-selector label { font-size: 12px; color: #475569; }
.range-selector input { min-width: 0; width: 112px; min-height: 44px; border: 1px solid var(--editor-line); border-radius: 7px; padding: 8px; }
.pdf-editor .editor-button, .editor-preview-dialog .editor-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 1px solid var(--editor-line); border-radius: 7px; background: #fff; color: #1e293b; padding: 8px 11px; font-size: 13px; font-weight: 600; line-height: 1.35; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.pdf-editor .editor-button:hover:not(:disabled), .editor-preview-dialog .editor-button:hover { background: #eff6ff; border-color: #93b4ed; transform: none; }
.pdf-editor .editor-button:disabled { cursor: default; color: #64748b; background: #f1f5f9; border-color: #e2e8f0; opacity: .65; }
.pdf-editor :focus-visible, .editor-preview-dialog :focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.pdf-editor .editor-button:focus-visible, .editor-preview-dialog .editor-button:focus-visible { position: relative; z-index: 1; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 12px 14px; border: 1px solid var(--editor-line); background: #f8fafc; border-radius: 0 0 12px 12px; position: sticky; top: 8px; z-index: 5; }
.pdf-editor .editor-danger { color: #b91c1c; }
.pdf-editor .editor-danger:hover:not(:disabled) { background: #fff1f2; border-color: #fda4af; }
.editor-more { position: relative; }
.editor-more summary { list-style: none; }
.editor-more summary::after { content: '⌄'; margin-left: 6px; }
.editor-more summary::-webkit-details-marker { display: none; }
.editor-more-menu { position: absolute; top: calc(100% + 6px); right: 0; width: 220px; display: grid; gap: 4px; padding: 8px; background: #fff; border: 1px solid var(--editor-line); border-radius: 9px; box-shadow: 0 8px 24px #13243a1f; z-index: 8; }
.editor-more-menu .editor-button { justify-content: flex-start; }
.selection-help { font-size: 12px; line-height: 1.5; color: #475569; margin: 12px 2px 14px; }
.editor-pages { list-style: none; padding: 18px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; background: #edf2f7; border: 1px solid #dde5ee; border-radius: 12px; }
.editor-pages:empty { display: none; }
.editor-page { min-width: 0; background: #fff; border: 2px solid transparent; border-radius: 9px; overflow: hidden; box-shadow: 0 2px 6px #13243a0c; }
.editor-page.is-selected { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 2px #2563eb15; }
.page-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 3px; padding: 0 6px; }
.page-choice { display: flex; align-items: center; gap: 7px; min-height: 44px; cursor: pointer; font-size: 12px; font-weight: 650; min-width: 0; }
.page-select { width: 18px; height: 18px; margin: 0; accent-color: #2563eb; cursor: pointer; flex-shrink: 0; }
.page-number { font-family: ui-monospace, "SFMono-Regular", monospace; white-space: nowrap; }
.pdf-editor .page-drag { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-height: 44px; min-width: 44px; font-size: 11px; color: #475569; background: transparent; padding: 4px; border: 0; border-radius: 4px; cursor: grab; touch-action: none; }
.page-drag span:first-child { font-size: 22px; }
.pdf-editor .page-drag:hover { background: #e2e8f0; }
.pdf-editor .page-preview { display: flex; position: relative; align-items: center; justify-content: center; width: calc(100% - 12px); height: 216px; margin: 0 6px; background: #e7edf4; border: 0; border-radius: 4px; padding: 12px; cursor: zoom-in; overflow: hidden; }
.pdf-editor .page-preview:hover { background: #dce6f3; }
.page-artwork { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: 0 2px 7px #13243a26; background: #fff; }
.page-open { position: absolute; bottom: 8px; right: 8px; padding: 5px 8px; border-radius: 5px; background: #fff; color: #334155; font-size: 11px; border: 1px solid #cbd5e1; opacity: 1; }
.page-preview:hover .page-open, .page-preview:focus-visible .page-open, .preview-failed .page-open { opacity: 1; }
.page-source { font-size: 11px; color: #475569; margin: 9px 9px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-edits { min-height: 19px; color: #1d4ed8; font-size: 11px; font-weight: 600; padding: 0 9px 9px; line-height: 1.5; }
.page-drag-ghost { opacity: .35; }
.page-drag-chosen { border-color: #2563eb; }
.editor-sidebar { display: grid; gap: 16px; position: sticky; top: 20px; }
.editor-output { background: #fff; border: 1px solid var(--editor-line); border-radius: 12px; padding: 22px; }
.editor-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .05em; color: #475569; }
.editor-output h2 { margin: 9px 0 8px; font-size: 21px; letter-spacing: -.035em; font-weight: 650; }
.export-summary { font-size: 13px; color: #475569; line-height: 1.6; margin: 0 0 18px; }
.editor-output .editor-button { width: 100%; margin-bottom: 9px; }
.pdf-editor .editor-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.pdf-editor .editor-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.pdf-editor .editor-share { border-color: transparent; margin: 0; }
.editor-note { color: #475569; font-size: 12px; line-height: 1.6; margin: 12px 0 0; }
.editor-advanced { border: 1px solid var(--editor-line); border-radius: 12px; background: #fff; padding: 18px; }
.editor-advanced h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-size: 15px; }
#alignmentSummary { color: #475569; font-size: 11px; font-weight: 400; }
.editor-advanced .editor-button { width: 100%; margin-top: 16px; }
.editor-draft-note { color: #64748b; font-size: 12px; line-height: 1.6; margin: 0 4px; }
.editor-status { min-height: 22px; font-size: 13px; color: #334155; line-height: 1.6; margin: 12px 2px; }
.editor-empty { padding: 50px 24px; text-align: center; border: 1px dashed #b6c5d6; background: #edf2f7; border-radius: 12px; }
.editor-empty p { color: #475569; font-size: 14px; }
.editor-error { color: #b91c1c; font-size: 13px; line-height: 1.6; }
.editor-error.validation-summary-valid { display: none; }
.editor-preview-dialog { width: min(1000px, 94vw); max-height: 94dvh; border: 1px solid #cbd5e1; border-radius: 12px; padding: 20px; color: #1e293b; background: #edf2f7; }
.editor-preview-dialog::backdrop { background: #13243acc; }
.preview-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.preview-dialog-heading h2 { font-size: 16px; margin: 0; }
#previewImage { display: block; max-width: 100%; max-height: 76dvh; width: auto; height: auto; margin: auto; background: #fff; box-shadow: 0 3px 14px #13243a24; }
#previewImage[hidden], [hidden] { display: none !important; }
@media (max-width: 1050px) {
    .editor-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; }
    .editor-pages { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; padding: 12px; }
    .editor-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
}
@media (max-width: 760px) {
    .container-wide { padding: 16px; }
    .pdf-editor { margin-top: 4px; }
    .editor-layout { grid-template-columns: minmax(0, 1fr); }
    .editor-sidebar { position: static; }
    .editor-jumps { position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; padding: 8px; margin: 0 0 16px; border: 1px solid #cbd5e1; border-radius: 11px; background: #fff; box-shadow: 0 4px 20px #13243a14; }
    .editor-jumps a, .editor-jumps button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; flex: 1; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; color: #1e293b; font-size: 13px; font-weight: 600; cursor: pointer; }
    .pdf-editor [id], .pdf-editor button, .pdf-editor input { scroll-margin-block: 80px 16px; }
    .editor-return { display: flex; justify-content: center; align-items: center; min-height: 44px; font-size: 13px; }
    .editor-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; }
    .editor-selection { padding: 14px; }
    .page-actions { position: static; padding: 10px; gap: 6px; }
    .pdf-editor:not(.has-selection) .page-actions { display: none; }
    .page-actions > .editor-button, .page-actions > .editor-more { flex: 1 1 135px; }
    .editor-more > summary { width: 100%; }
    .editor-more-menu { left: 0; right: auto; }
    .pdf-editor .page-preview { height: 190px; padding: 8px; }
    .page-drag span:last-child { display: none; }
    .range-selector { flex-basis: 100%; }
    .range-selector input { flex: 1; }
    .editor-history { width: 100%; }
    .editor-history .editor-button { flex: 1; }
    .editor-status { margin-bottom: 0; }
}
@media (max-width: 360px) {
    .editor-pages { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .pdf-editor *, .editor-preview-dialog * { transition: none !important; scroll-behavior: auto !important; }
}
.pdf-upload.card { max-width: 660px; }
.pdf-upload h1 { font-size: 30px; letter-spacing: -.035em; }
.pdf-upload .pdf-dropzone { width: 100%; min-height: 200px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; background: #f8fafc; color: #1e293b; font: inherit; border: 2px dashed #a8bbd3; }
.pdf-upload .pdf-dropzone:hover:not(:disabled), .pdf-upload .pdf-dropzone.dragover { background: #eff6ff; border-color: #2563eb; }
.pdf-upload .pdf-dropzone:focus-visible { outline: 3px solid #2563eb; outline-offset: 4px; }
.upload-paper { font-size: 34px; margin-bottom: 4px; }
.pdf-upload .pdf-dropzone span:last-child { font-size: 13px; font-weight: 400; color: #475569; }
.pdf-upload .file-list { padding: 0; }
.pdf-upload .file-list li { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.pdf-upload .file-list li span { overflow-wrap: anywhere; }
.pdf-upload .file-list button { min-height: 44px; font-size: 12px; flex-shrink: 0; }
.pdf-upload button:disabled { opacity: .55; cursor: default; transform: none; }
.pdf-progress p { font-size: 13px; line-height: 1.6; }
.pdf-progress progress { width: 100%; height: 12px; accent-color: #2563eb; }
@media (max-width: 600px) { .pdf-upload.card { padding: 20px; margin-top: 10px; } }

/* A single adjustment workspace keeps the draft beside its preview. */
.editor-adjustment-dialog { width: min(1120px, 96vw); height: min(840px, 94dvh); max-width: none; max-height: 96dvh; padding: 0; margin: auto; border: 1px solid #b6c5d6; border-radius: 14px; background: #fff; overflow: hidden; box-shadow: 0 24px 80px #13243a40; }
.editor-adjustment-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.editor-adjustment-dialog::backdrop { background: #13243abf; }
body:has(.editor-adjustment-dialog[open]) { overflow: hidden; }
.adjustment-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid #dde5ee; }
.adjustment-heading h2 { font-size: 21px; margin: 0; letter-spacing: -.025em; }
.adjustment-heading p { font-size: 12px; color: #475569; margin: 5px 0 0; }
.adjustment-history, .adjustment-footer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.adjustment-body { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.adjustment-controls { overflow: auto; padding: 20px 22px; scrollbar-gutter: stable; scroll-padding-block: 12px; }
.adjustment-scope { border: 0; padding: 0; margin: 0; }
.adjustment-scope legend { font-size: 13px; font-weight: 650; margin-bottom: 7px; }
.adjustment-scope label { display: flex; align-items: center; gap: 9px; min-height: 36px; margin: 0; font-size: 13px; font-weight: 500; cursor: pointer; }
.adjustment-scope input, .adjustment-guides-toggle input { width: 18px; height: 18px; accent-color: #2563eb; margin: 0; flex-shrink: 0; }
.adjustment-scope input:disabled + span { color: #64748b; }
.adjustment-tabs { display: flex; gap: 4px; margin: 20px 0; padding: 4px; border-radius: 9px; background: #edf2f7; }
.adjustment-tabs button { min-height: 44px; flex: 1; padding: 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #475569; cursor: pointer; font-size: 13px; font-weight: 600; }
.adjustment-tabs button[aria-selected="true"] { background: #fff; color: #1d4ed8; border-color: #cbd5e1; box-shadow: 0 1px 3px #13243a14; }
.adjustment-controls h3 { font-size: 17px; margin: 0 0 8px; }
.adjustment-controls .editor-note { margin: 8px 0 12px; }
.adjustment-controls section label, .preview-zoom label { display: block; font-size: 12px; font-weight: 600; margin: 14px 0 6px; }
.adjustment-controls section input, .adjustment-controls select, .adjustment-preview select { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid #a8bbd3; border-radius: 7px; background: #fff; color: #1e293b; }
.adjustment-controls input[aria-invalid="true"] { border-color: #b91c1c; background: #fff1f2; }
.adjustment-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field-note { display: block; color: #475569; font-size: 11px; line-height: 1.5; margin: 6px 0; }
.adjustment-mixed-help { padding-top: 14px; border-top: 1px solid #e2e8f0; }
.adjustment-controls #resetAdjustmentToolBtn { width: 100%; margin: 8px 0; }
.adjustment-preview { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 18px; background: #edf2f7; border-left: 1px solid #dde5ee; }
.adjustment-preview-toolbar, .adjustment-page-picker { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.preview-comparison { display: flex; gap: 8px; }
.preview-comparison button[aria-pressed="true"] { color: #1d4ed8; background: #eff6ff; border-color: #2563eb; }
.preview-zoom { display: flex; gap: 8px; align-items: center; }
.preview-zoom label { margin: 0; }
.preview-zoom select { width: 88px; }
.adjustment-page-picker select { flex: 1; max-width: 220px; }
.adjustment-stage { flex: 1; min-height: 0; overflow: auto; border: 1px solid #cbd5e1; border-radius: 5px; background: #dce4ee; overscroll-behavior: contain; }
.adjustment-preview-centering { display: flex; align-items: center; justify-content: center; min-width: 100%; min-height: 100%; width: max-content; padding: 16px; box-sizing: border-box; }
.adjustment-paper { position: relative; flex-shrink: 0; background: #fff; box-shadow: 0 2px 9px #13243a26; overflow: hidden; }
#adjustmentImage { display: block; width: 100%; height: 100%; object-fit: fill; }
#adjustmentImage.is-updating { opacity: .45; }
#adjustmentGuides { position: absolute; border: 1px dashed #1d4ed8; outline: 1px solid #fff; pointer-events: none; }
.adjustment-preview-status { font-size: 12px; line-height: 1.5; margin: 0; min-height: 18px; color: #334155; }
.adjustment-guides-toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; min-height: 32px; }
.adjustment-guides-toggle span { color: #475569; }
.adjustment-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; border-top: 1px solid #cbd5e1; background: #fff; }
.adjustment-footer p { background: #fff; margin: 0; font-size: 12px; line-height: 1.5; max-width: 420px; }
.adjustment-footer-actions { flex-shrink: 0; }
@media (max-width: 700px) {
    .editor-adjustment-dialog { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
    .adjustment-heading { padding: 12px 14px; gap: 8px; }
    .adjustment-heading h2 { font-size: 18px; }
    .adjustment-heading p { font-size: 11px; }
    .adjustment-history { gap: 8px; flex-wrap: nowrap; }
    .adjustment-history .editor-button { padding: 8px; }
    .adjustment-body { display: flex; flex-direction: column; }
    .adjustment-preview { order: -1; height: 300px; flex-shrink: 0; padding: 10px 14px; gap: 6px; border: 0; border-bottom: 1px solid #cbd5e1; }
    .adjustment-preview-toolbar .editor-button { min-height: 36px; padding: 5px 10px; }
    .preview-zoom select { min-height: 36px; padding: 4px; }
    .adjustment-page-picker { gap: 8px; }
    .adjustment-page-picker .editor-button { min-height: 32px; width: 32px; padding: 4px; background: #ffffffed; }
    .adjustment-page-picker select { position: static; width: 70px; min-height: 32px; padding: 4px; font-size: 11px; }
    .adjustment-guides-toggle { min-height: 26px; font-size: 11px; }
    .adjustment-guides-toggle input { width: 16px; height: 16px; }
    .adjustment-preview-status { font-size: 11px; }
    .adjustment-controls { flex: 1; padding: 14px 20px; }
    .adjustment-tabs { margin: 12px 0; }
    .adjustment-footer { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 8px; }
    .adjustment-footer-actions { flex-wrap: nowrap; }
    .adjustment-footer-actions .editor-button { flex: 1; }
    .editor-adjustment-dialog button, .editor-adjustment-dialog input { scroll-margin-block: 12px; }
}
@media (max-width: 700px) and (max-height: 700px) {
    .adjustment-preview { display: grid; grid-template-columns: 100px minmax(0, 1fr); grid-template-rows: auto auto minmax(26px, 1fr) auto; height: 200px; column-gap: 10px; }
    .adjustment-stage { grid-column: 1; grid-row: 1 / 4; }
    .adjustment-preview-toolbar { grid-column: 2; grid-row: 1; flex-wrap: wrap; gap: 6px; }
    .preview-zoom { width: 100%; }
    .adjustment-page-picker { grid-column: 2; grid-row: 2; gap: 4px; }
    .adjustment-page-picker select { width: auto; }
    .adjustment-guides-toggle { grid-column: 2; grid-row: 3; }
    .adjustment-guides-toggle span { display: none; }
    .adjustment-preview-status { grid-column: 1 / -1; grid-row: 4; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .adjustment-heading p { display: none; }
}

.adjustment-tabs button:hover { background: #dce7f7; color: #1d4ed8; }
.pdf-editor button, .pdf-editor a { touch-action: manipulation; }
.adjustment-controls { overscroll-behavior: contain; }
.adjustment-preview-status, .adjustment-controls input { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .editor-jumps a:hover, .editor-jumps button:hover { background: #eff6ff; border-color: #93b4ed; } }
