.pfps-studio {
    --pfps-bg: #f4f6f8;
    --pfps-panel: #ffffff;
    --pfps-border: #d8dee6;
    --pfps-text: #17212b;
    --pfps-muted: #657181;
    --pfps-accent: #1d4ed8;
    --pfps-accent-soft: #e8efff;
    --pfps-danger: #b42318;
    --pfps-warning: #9a6700;
    --pfps-success: #027a48;
    color: var(--pfps-text);
    background: var(--pfps-bg);
    border: 1px solid var(--pfps-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 34px rgba(23, 33, 43, 0.08);
    min-width: 0;
}

.pfps-studio--admin {
    margin: 18px 20px 0 0;
}

.pfps-studio--frontend {
    margin: 24px auto;
    max-width: 1600px;
}

.pfps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 20px 22px;
    background: #101828;
    color: #fff;
}

.pfps-header h1 {
    color: #fff;
    font-size: 22px;
    line-height: 1.2;
    margin: 0 0 4px;
}

.pfps-header p {
    color: #cbd5e1;
    margin: 0;
}

.pfps-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pfps-header .button {
    min-height: 36px;
}

.pfps-notice {
    min-height: 22px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--pfps-border);
    background: #fff;
    font-weight: 500;
}

.pfps-notice--success { color: var(--pfps-success); background: #ecfdf3; }
.pfps-notice--error { color: var(--pfps-danger); background: #fef3f2; }
.pfps-notice--info { color: #344054; background: #f9fafb; }

.pfps-workspace {
    display: grid;
    grid-template-columns: 184px minmax(320px, 1fr) 330px;
    height: min(72vh, 850px);
    min-height: 610px;
}

.pfps-sidebar,
.pfps-viewer-panel {
    min-width: 0;
    min-height: 0;
}

.pfps-sidebar {
    background: var(--pfps-panel);
}

.pfps-sidebar--pages {
    border-right: 1px solid var(--pfps-border);
    display: flex;
    flex-direction: column;
}

.pfps-sidebar--tools {
    border-left: 1px solid var(--pfps-border);
    overflow-y: auto;
}

.pfps-sidebar-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 14px 8px;
}

.pfps-sidebar-heading h2 {
    margin: 0;
    font-size: 14px;
}

.pfps-sidebar-heading span {
    color: var(--pfps-muted);
    font-size: 12px;
}

.pfps-page-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 0 12px 10px;
}

.pfps-page-actions .button {
    display: inline-flex;
    justify-content: center;
    padding: 0;
    min-width: 0;
    font-size: 17px;
}

.pfps-thumbnails {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 18px;
}

.pfps-empty-state {
    padding: 24px 10px;
    color: var(--pfps-muted);
    text-align: center;
    font-size: 12px;
}

.pfps-thumbnail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 9px 6px 7px;
    margin: 0 0 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    color: var(--pfps-muted);
}

.pfps-thumbnail:hover {
    background: #f8fafc;
}

.pfps-thumbnail.is-selected {
    background: var(--pfps-accent-soft);
    border-color: var(--pfps-accent);
    color: var(--pfps-accent);
}

.pfps-thumbnail.is-dragging { opacity: 0.45; }
.pfps-thumbnail.is-drag-over { border-color: #7c3aed; }

.pfps-thumbnail canvas {
    max-width: 118px;
    max-height: 150px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
}

.pfps-thumbnail span {
    font-size: 11px;
    font-weight: 600;
}

.pfps-viewer-panel {
    display: flex;
    flex-direction: column;
    background: #d7dce2;
}

.pfps-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 48px;
    padding: 7px 10px;
    background: #fff;
    border-bottom: 1px solid var(--pfps-border);
}

.pfps-toolbar-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pfps-toolbar-group--right {
    margin-left: auto;
}

.pfps-page-number {
    width: 58px;
    min-height: 30px !important;
    text-align: center;
}

.pfps-zoom {
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pfps-canvas-wrap {
    position: relative;
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 28px;
}

.pfps-canvas-wrap canvas {
    display: block;
    background: #fff;
    box-shadow: 0 6px 24px rgba(16, 24, 40, 0.28);
}

.pfps-canvas-placeholder {
    align-self: center;
    max-width: 390px;
    padding: 38px;
    border: 2px dashed rgba(71, 84, 103, 0.45);
    border-radius: 14px;
    color: #475467;
    text-align: center;
    background: rgba(255, 255, 255, 0.45);
}

.pfps-canvas-placeholder .dashicons {
    display: block;
    width: auto;
    height: auto;
    margin-bottom: 10px;
    font-size: 48px;
}

.pfps-canvas-placeholder strong {
    display: block;
    color: #1d2939;
    font-size: 18px;
}

.pfps-canvas-placeholder p {
    margin: 8px 0 0;
}

.pfps-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-bottom: 1px solid var(--pfps-border);
}

.pfps-tab {
    padding: 13px 8px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--pfps-muted);
    font-weight: 600;
    cursor: pointer;
}

.pfps-tab.is-active {
    border-bottom-color: var(--pfps-accent);
    color: var(--pfps-accent);
}

.pfps-tab-panel {
    padding: 16px;
}

.pfps-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.pfps-field label {
    font-size: 12px;
    font-weight: 600;
    color: #344054;
}

.pfps-field input,
.pfps-field select {
    width: 100%;
    max-width: none;
}

.pfps-grid {
    display: grid;
    gap: 10px;
}

.pfps-grid--2 {
    grid-template-columns: 1fr 1fr;
}

.pfps-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 9px 0;
    color: #344054;
}

.pfps-checkbox input {
    margin-top: 2px;
}

.pfps-estimate {
    margin: 16px 0 12px;
    padding: 10px 12px;
    border-radius: 7px;
    background: #f2f4f7;
    color: #344054;
    font-size: 12px;
    line-height: 1.5;
}

.pfps-generate,
.pfps-secondary-action {
    width: 100%;
    justify-content: center;
}

.pfps-secondary-action {
    margin-top: 8px !important;
}

.pfps-preflight-summary {
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
    line-height: 1.55;
}

.pfps-preflight-list {
    margin-top: 12px;
}

.pfps-preflight-item {
    display: grid;
    grid-template-columns: 10px 1fr;
    align-items: start;
    gap: 9px;
    padding: 8px 0;
    border-bottom: 1px solid #edf0f3;
}

.pfps-preflight-item > span {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    border-radius: 50%;
    background: #98a2b3;
}

.pfps-preflight-item p { margin: 0; }
.pfps-preflight-item--pass > span { background: #12b76a; }
.pfps-preflight-item--warning > span { background: #f79009; }
.pfps-preflight-item--info > span { background: #2e90fa; }
.pfps-status-warning { color: var(--pfps-warning); }
.pfps-status-pass { color: var(--pfps-success); }

.pfps-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 34px;
    padding: 7px 14px;
    border-top: 1px solid var(--pfps-border);
    background: #fff;
    color: var(--pfps-muted);
    font-size: 11px;
}

.pfps-studio.is-busy {
    cursor: progress;
}

.pfps-studio.is-busy .pfps-canvas-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.pfps-access-message {
    padding: 14px;
    border-left: 4px solid #d63638;
    background: #fff;
}

@media (max-width: 1180px) {
    .pfps-workspace {
        grid-template-columns: 150px minmax(300px, 1fr) 290px;
    }
}

@media (max-width: 900px) {
    .pfps-workspace {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .pfps-sidebar--pages {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--pfps-border);
    }

    .pfps-thumbnails {
        display: flex;
        gap: 8px;
        min-height: 170px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .pfps-thumbnail {
        min-width: 140px;
    }

    .pfps-viewer-panel {
        min-height: 560px;
    }

    .pfps-sidebar--tools {
        order: 3;
        border-left: 0;
        border-top: 1px solid var(--pfps-border);
    }
}

@media (max-width: 620px) {
    .pfps-header,
    .pfps-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .pfps-header-actions,
    .pfps-toolbar-group {
        width: 100%;
    }

    .pfps-toolbar-group--right {
        margin-left: 0;
    }

    .pfps-grid--2 {
        grid-template-columns: 1fr;
    }

    .pfps-canvas-wrap {
        padding: 14px;
    }
}

/* Automatic layout guidance. */
.pfps-checkbox--automatic {
    margin: 12px 0 14px;
    padding: 10px 11px;
    border: 1px solid #b8d7ff;
    border-radius: 8px;
    background: #eff8ff;
}

.pfps-checkbox--automatic strong {
    color: #175cd3;
}

.pfps-checkbox--automatic small {
    color: #475467;
    line-height: 1.35;
}

.pfps-field input[readonly] {
    background: #f2f4f7;
    color: #475467;
}

.pfps-estimate-warning {
    color: #b54708;
}

.pfps-estimate-success {
    color: #067647;
}

/* PDF editor workspace. */
.pfps-workspace {
    grid-template-columns: 184px minmax(340px, 1fr) 370px;
}

.pfps-page-stage {
    position: relative;
    flex: 0 0 auto;
    background: #fff;
    box-shadow: 0 6px 24px rgba(16, 24, 40, 0.28);
}

.pfps-page-stage > canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    box-shadow: none;
}

.pfps-text-layer,
.pfps-edit-layer {
    position: absolute;
    inset: 0;
}

.pfps-text-layer {
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.pfps-text-layer.is-active {
    pointer-events: auto;
}

.pfps-text-item {
    position: absolute;
    padding: 0;
    border: 1px solid transparent;
    background: rgba(37, 99, 235, 0.02);
    color: transparent;
    cursor: text;
}

.pfps-text-layer.is-active .pfps-text-item:hover,
.pfps-text-item.is-selected {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.16);
}

.pfps-edit-layer {
    z-index: 3;
    overflow: visible;
    touch-action: none;
    user-select: none;
}

.pfps-edit-layer[data-tool="edit-text"] {
    pointer-events: none;
}

.pfps-edit-layer[data-tool="add-text"] { cursor: text; }
.pfps-edit-layer[data-tool="whiteout"],
.pfps-edit-layer[data-tool="redact"],
.pfps-edit-layer[data-tool="highlight"],
.pfps-edit-layer[data-tool="rectangle"],
.pfps-edit-layer[data-tool="line"],
.pfps-edit-layer[data-tool="image"] { cursor: crosshair; }
.pfps-edit-layer[data-tool="freehand"] { cursor: cell; }

.pfps-edit-object {
    pointer-events: all;
    cursor: pointer;
}

.pfps-edit-object.is-selected,
.pfps-edit-object.is-selected > * {
    stroke: #2563eb !important;
    stroke-width: 2 !important;
    stroke-dasharray: 5 3;
}

.pfps-tabs {
    grid-template-columns: repeat(3, 1fr);
}

.pfps-editor-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.pfps-editor-actions .button {
    justify-content: center;
    min-width: 0;
    padding-inline: 7px;
}

.pfps-editor-actions .button.is-active {
    border-color: #1d4ed8;
    background: #e8efff;
    color: #1d4ed8;
    box-shadow: inset 0 0 0 1px #1d4ed8;
}

.pfps-editor-history {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.pfps-editor-history .button {
    justify-content: center;
    min-width: 0;
    padding-inline: 4px;
}

.pfps-editor-status {
    min-height: 38px;
    margin: 0 0 12px;
    padding: 9px 10px;
    border: 1px solid #b8d7ff;
    border-radius: 7px;
    background: #eff8ff;
    color: #175cd3;
    font-size: 12px;
    line-height: 1.4;
}

.pfps-tab-panel textarea[data-pfps-edit] {
    width: 100%;
    resize: vertical;
}

.pfps-tab-panel input[type="color"] {
    min-height: 36px;
    padding: 2px;
}

.pfps-checkbox--compact {
    margin-top: 8px;
    align-items: flex-start;
    font-size: 12px;
}

.pfps-fill-field .description {
    margin-top: 6px;
}

.pfps-edit-object.is-selected > .pfps-replacement-text {
    stroke: none !important;
    stroke-width: 0 !important;
    stroke-dasharray: none !important;
}

.pfps-editor-primary {
    width: 100%;
    justify-content: center;
    margin: 0 0 8px !important;
}

@media (max-width: 1180px) {
    .pfps-workspace {
        grid-template-columns: 150px minmax(300px, 1fr) 330px;
    }
}

.pfps-thumbnail {
    position: relative;
}

.pfps-thumbnail.has-edits::after {
    content: 'Edited';
    position: absolute;
    top: 5px;
    right: 4px;
    padding: 2px 4px;
    border-radius: 999px;
    background: #7c3aed;
    color: #fff;
    font-size: 8px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}


.pfps-font-detection {
    margin: 10px 0;
    padding: 10px 12px;
    border: 1px solid #c3c4c7;
    border-left: 4px solid #2271b1;
    border-radius: 3px;
    background: #f6f7f7;
    font-size: 12px;
    line-height: 1.5;
}

.pfps-font-detection strong {
    color: #1d2327;
}

.pfps-font-detection [data-pfps-font-match] {
    color: #50575e;
}

/* Advanced production imposition controls. */
.pfps-impose-section {
    margin: 0 0 10px;
    border: 1px solid var(--pfps-border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.pfps-impose-section > summary {
    cursor: pointer;
    padding: 11px 12px;
    font-weight: 700;
    font-size: 13px;
    background: #f8fafc;
    border-bottom: 1px solid transparent;
    user-select: none;
}

.pfps-impose-section[open] > summary {
    border-bottom-color: var(--pfps-border);
}

.pfps-impose-section__body {
    padding: 12px;
}

.pfps-impose-section .pfps-field:last-child,
.pfps-impose-section .pfps-checkbox:last-child {
    margin-bottom: 0;
}

.pfps-sidebar--tools .pfps-tab-panel[data-pfps-panel="impose"] {
    padding-bottom: 18px;
}

.pfps-sidebar--tools .pfps-tab-panel[data-pfps-panel="impose"] > .pfps-estimate {
    margin-top: 14px;
}

@media (min-width: 1280px) {
    .pfps-workspace {
        grid-template-columns: 184px minmax(360px, 1fr) 390px;
    }
}

/* Simplified booklet workflow and verified sheet guide. */
.pfps-booklet-intro {
    margin: 0 0 12px;
    padding: 11px 12px;
    border: 1px solid #b8d7ff;
    border-radius: 8px;
    background: #eff8ff;
    color: #17324d;
}

.pfps-booklet-intro p {
    margin: 5px 0 0;
    font-size: 12px;
    line-height: 1.45;
}

.pfps-booklet-guide {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid #a7d7b5;
    border-radius: 8px;
    background: #f0fdf4;
    color: #173b24;
    font-size: 12px;
    line-height: 1.45;
}

.pfps-booklet-guide__summary {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
}

.pfps-booklet-order-note {
    margin: 8px 0;
    padding: 8px 9px;
    border-left: 4px solid #dba617;
    background: #fff8db;
    color: #5c4300;
}

.pfps-booklet-table-wrap {
    max-height: 310px;
    overflow: auto;
    border: 1px solid #c6dfcd;
    border-radius: 6px;
    background: #fff;
}

.pfps-booklet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.pfps-booklet-table th,
.pfps-booklet-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #e5eee7;
    text-align: left;
    vertical-align: top;
}

.pfps-booklet-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #e8f5ec;
}

.pfps-booklet-table tbody th {
    white-space: nowrap;
}

.pfps-booklet-table td small {
    display: block;
    margin-top: 2px;
    color: #667085;
}

.pfps-booklet-advanced {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--pfps-border);
}

.pfps-booklet-advanced h3 {
    margin: 0 0 10px;
    font-size: 13px;
}

.pfps-font-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 7px;
}

.pfps-font-actions .button {
    margin: 0;
}

/* 1.8.0 scanned-text recognition and style controls */
.pfps-text-item.is-ocr {
    border: 1px dashed rgba(37, 99, 235, .55);
    background: rgba(37, 99, 235, .05);
}
.pfps-ocr-field .button {
    min-height: 40px;
}
@media (max-width: 720px) {
    .pfps-ocr-field .button { width: 100%; }
}
