*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* EducationPro public utility palette */
    --bg: hsl(210 35% 98%);
    --surface: hsl(0 0% 100% / 0.92);
    --surface-hover: hsl(210 35% 96%);
    --border: hsl(214 24% 86%);
    --border-focus: hsl(236 51% 31%);
    --text: hsl(224 55% 12%);
    --text-secondary: hsl(221 18% 40%);
    --text-muted: hsl(221 18% 52%);
    --primary: hsl(236 51% 31%);
    --accent: hsl(356 72% 46%);
    --accent-hover: hsl(356 75% 40%);
    --accent-light: hsl(356 72% 46% / 0.08);
    --success: hsl(140 65% 28%);
    --warning: hsl(34 82% 35%);
    --error: hsl(0 76% 43%);
    --radius: 1rem;
    --radius-sm: .65rem;
    --shadow-sm: 0 3px 10px hsl(224 30% 16% / 0.06);
    --shadow: 0 8px 18px hsl(224 42% 16% / 0.09);
    --shadow-lg: 0 18px 40px hsl(224 42% 16% / 0.13);
    --transition: 180ms ease;
    --font-sans: "Source Sans 3", sans-serif;
    --font-display: "Fraunces", serif;
    --font: var(--font-sans);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    letter-spacing: -.02em;
    line-height: 1.1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 2.65rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .68rem 1.05rem;
    font: inherit;
    font-size: .94rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid hsl(356 72% 46% / .45); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 14px hsl(356 72% 46% / .2); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: hsl(236 51% 31% / .08); }
.btn-lg { min-height: 3rem; padding-inline: 1.25rem; }


/* Public workspace container */
.workspace {
    padding: 0 0 120px;
    /* Keep the workspace background consistent with the public shell */
    background: var(--bg);
    border-radius: var(--radius);
}

.workspace-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid #f5c26b;
    background: #fff7e6;
    color: #8a5600;
    font-size: 14px;
}

.workspace-alert.hidden {
    display: none;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

body.session-expired .drop-zone {
    opacity: 0.6;
    cursor: not-allowed;
}

.drop-zone.drag-over .drop-icon {
    transform: translateY(-4px);
    color: var(--accent);
}

.drop-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
    transition: transform var(--transition), color var(--transition);
}

.drop-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.drop-browse-btn {
    margin: 8px 0 16px;
}

.drop-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.word-mode-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

.word-mode-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
}

.word-mode-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.target-size-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

/* PDF → Word toggle uses the same styling as merge toggle; keep spacing consistent */
#modeToggleLabel {
    margin-right: -4px;
}

.size-input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.size-input {
    width: 64px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
}

.size-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.selection-count {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Buttons - Inherited from global style.css */
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Local overrides if needed (mostly handled globally now) */
.btn-icon {
    display: flex;
}

/* Merge Toggle */
.merge-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.merge-toggle input {
    display: none;
}

.toggle-track {
    width: 44px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    position: relative;
    transition: background var(--transition);
}

.merge-toggle input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform var(--transition);
}

.merge-toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* File Card */
.file-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: 260px 360px;
}

.file-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.file-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.file-card.merge-highlight {
    border-color: var(--accent);
    background: var(--accent-light);
}

.card-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition);
}

.file-card.selected .card-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.card-checkbox svg {
    opacity: 0;
    transition: opacity var(--transition);
}

.file-card.selected .card-checkbox svg {
    opacity: 1;
}

.card-preview {
    width: 100%;
    aspect-ratio: 5 / 7;
    background: #f0f0f3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-preview .type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Type badge colors */
.type-badge.pdf   { background: #ffe5e5; color: #cc3333; }
.type-badge.doc,
.type-badge.docx  { background: #e0edff; color: #2b6cb0; }
.type-badge.xls,
.type-badge.xlsx  { background: #dcfce7; color: #16a34a; }
.type-badge.ppt,
.type-badge.pptx  { background: #fde8e8; color: #c53030; }
.type-badge.odt,
.type-badge.ods,
.type-badge.odp   { background: #e8f4fd; color: #2b6cb0; }
.type-badge.jpg,
.type-badge.jpeg,
.type-badge.png,
.type-badge.gif,
.type-badge.bmp,
.type-badge.webp,
.type-badge.tiff,
.type-badge.tif   { background: #fef3c7; color: #b45309; }
.type-badge.heic,
.type-badge.heif  { background: #f3e8ff; color: #7c3aed; }
.type-badge.svg   { background: #fef3c7; color: #b45309; }
.type-badge.csv,
.type-badge.txt   { background: #f0f0f3; color: #6e6e73; }
.type-badge.rtf   { background: #e0edff; color: #2b6cb0; }
.type-badge.pages { background: #fff7ed; color: #c2410c; }

.card-info {
    padding: 12px 14px;
}

.card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Status Indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.pending    { background: var(--text-muted); }
.status-dot.uploading  { background: var(--accent); animation: pulse 1.2s infinite; }
.status-dot.converting { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.ready      { background: var(--success); }
.status-dot.error      { background: var(--error); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-label {
    text-transform: capitalize;
}

/* Spinner */
.card-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Process Bar */
.process-bar {
    position: fixed;
    bottom: 0;
    left: 260px; /* full-width public utility */
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    z-index: 100;
}

.process-bar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.process-status {
    font-size: 14px;
    color: var(--text-secondary);
}

.process-status.is-warning {
    color: #8a5600;
    font-weight: 600;
}

.progress-bar {
    height: 3px;
    background: var(--border);
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 300ms ease;
}

/* Drag reorder */
.file-card[draggable="true"] {
    cursor: grab;
}

.file-card[draggable="true"]:active {
    cursor: grabbing;
}

.file-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.file-card.drag-over-card {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    transform: translateY(-2px);
}

/* Merge order badge */
.order-badge {
    position: absolute;
    top: 10px;
    left: 40px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Rotation label on preview */
.rot-label {
    position: absolute;
    bottom: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 4;
}

.page-selection-badge {
    right: 8px;
    background: var(--success) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rot-label:not(.page-selection-badge) {
    left: 8px;
}


/* Thumbnail rotation */
.thumb-img.rot90  { transform: rotate(90deg); }
.thumb-img.rot180 { transform: rotate(180deg); }
.thumb-img.rot270 { transform: rotate(270deg); }

/* Sort up/down buttons */
.card-sort-btns {
    position: absolute;
    bottom: 56px;
    right: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.file-card:hover .card-sort-btns {
    opacity: 1;
}

.sort-btn {
    width: 26px;
    height: 22px;
    border-radius: 5px;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition);
}

.sort-btn:hover:not(:disabled) {
    background: rgba(0,0,0,0.8);
}

.sort-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* Card action buttons */
.card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.file-card:hover .card-actions {
    opacity: 1;
}

.card-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition);
}

.card-action-btn:hover {
    background: rgba(0,0,0,0.75);
}

.card-select-pages-btn {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
    white-space: nowrap;
    z-index: 3;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.file-card:hover .card-select-pages-btn {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}


/* Error tooltip on card */
.card-error-msg {
    font-size: 11px;
    color: var(--error);
    margin-top: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 300ms ease forwards;
    max-width: 400px;
}

.toast.toast-error { background: var(--error); }
.toast.toast-success { background: #1a7f37; }

.toast.toast-out {
    animation: toastOut 300ms ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* File size in meta */
.card-size {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

/* Compact drop zone */
.drop-zone.has-files {
    padding: 24px;
    border-style: solid;
    border-color: var(--border);
}

.drop-zone.has-files .drop-zone-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.drop-zone.has-files .drop-icon {
    margin-bottom: 0;
}

.drop-zone.has-files .drop-icon svg {
    width: 20px;
    height: 20px;
}

.drop-zone.has-files .drop-browse-btn {
    margin: 0;
    padding: 6px 12px;
    font-size: 13px;
    order: 3;
}

.drop-zone.has-files .drop-text {
    font-size: 14px;
    margin-bottom: 0;
}

.drop-zone.has-files .drop-hint {
    display: none;
}

/* ========== Preview Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 200ms ease;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-container {
    background: var(--surface);
    border-radius: 16px;
    width: 90vw;
    max-width: 900px;
    height: 85vh;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn 250ms ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 12px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    color: var(--text);
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}

.modal-close:hover {
    background: var(--border);
}

.modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f3;
}

.modal-body iframe,
.modal-body object {
    width: 100%;
    height: 100%;
    border: none;
}

.modal-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-error {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.modal-error p {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Wide modal for page editor */
.modal-wide {
    max-width: 1100px;
    width: 94vw;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

/* Page editor grid inside modal */
.modal-body-grid {
    display: block;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg);
    align-items: flex-start;
    justify-content: flex-start;
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.page-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
    transition: border-color var(--transition), box-shadow var(--transition);
    content-visibility: auto;
    contain-intrinsic-size: 220px 320px;
}

.page-card.rotated {
    border-color: var(--accent);
}

.page-canvas-wrap {
    width: 100%;
    aspect-ratio: 210 / 297;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.page-canvas-wrap canvas {
    max-width: 100%;
    max-height: 100%;
    transition: transform 200ms ease;
}

.page-canvas-wrap img.page-thumb {
    display: block;
    max-width: 100%;
    max-height: 100%;
    transition: transform 200ms ease;
}

.page-canvas-wrap canvas.rot90  { transform: rotate(90deg) scale(0.7); }
.page-canvas-wrap canvas.rot180 { transform: rotate(180deg); }
.page-canvas-wrap canvas.rot270 { transform: rotate(270deg) scale(0.7); }

.page-canvas-wrap .page-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page include checkbox */
.page-include-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    cursor: pointer;
    display: flex;
}

.page-include-check input {
    display: none;
}

.page-check-box {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.2);
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.page-include-check input:checked + .page-check-box {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(0,113,227,0.4);
}

.page-check-box svg {
    opacity: 0;
    transition: opacity var(--transition);
}

.page-include-check input:checked + .page-check-box svg {
    opacity: 1;
}

.page-include-check:hover .page-check-box {
    border-color: var(--accent);
    background: var(--accent-light);
}


/* Excluded page */
.page-card.page-excluded {
    opacity: 0.35;
}

.page-card.page-excluded .page-canvas-wrap {
    filter: grayscale(0.8);
}

.header-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.page-footer {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}

.page-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.page-rot-info {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

.page-rotate-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.page-rotate-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

/* Quick preview (disabled; page selection is sufficient) */
.modal-body-preview {
    display: block;
    overflow-y: auto;
    padding: 20px;
    background: #525659;
    align-items: flex-start;
}

.preview-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.preview-page-wrap {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    content-visibility: auto;
    contain-intrinsic-size: 760px 1080px;
}

.preview-page-wrap canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.preview-page-wrap img.preview-img {
    display: block;
    max-width: 100%;
    height: auto;
    transition: transform 200ms ease;
}

.preview-page-wrap canvas.rot90  { transform: rotate(90deg) scale(0.7); }
.preview-page-wrap canvas.rot180 { transform: rotate(180deg); }
.preview-page-wrap canvas.rot270 { transform: rotate(270deg) scale(0.7); }

/* Merge prompt dialog */
.prompt-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 440px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: modalIn 250ms ease;
}

.prompt-box h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.prompt-box p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-clear {
    color: var(--error);
    margin-left: 8px;
}

.btn-clear:hover:not(:disabled) {
    background: rgba(255, 59, 48, 0.08);
    color: var(--error);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.docforge-download-link {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    margin: 0 8px 0 4px;
}

.last-download-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    margin: 12px 0 14px;
}

.last-download-bar.hidden {
    display: none;
}

.last-download-title {
    font-size: 13px;
    color: var(--text-secondary);
}

.last-download-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--text-muted);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Keep the process bar full width on every public viewport */
@media (max-width: 768px) {
    .process-bar {
        left: 0;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .workspace {
        padding: 20px 16px 120px;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .drop-zone {
        padding: 40px 16px;
    }

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

    .toolbar-left, .toolbar-right {
        justify-content: center;
    }

    .process-bar-inner {
        flex-direction: column;
        text-align: center;
    }

    .modal-container {
        width: 96vw;
        height: 90vh;
        border-radius: 12px;
    }
}


/* EducationPro public utility shell */
/* EducationPro public utility shell */
.docforge-public-page { background: var(--bg); }
.docforge-public { width: min(1140px, 100% - 2rem); min-height: auto; margin: 0 auto; padding: 1.5rem 0 6rem; }
/* Tool-first intro: the upload surface is the hero, not a large dashboard banner. */
.docforge-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin: 0 0 1.15rem; padding: 0 0 .9rem; border-bottom: 1px solid var(--line); }
.docforge-title { color: var(--text); font-size: clamp(1.8rem, 3vw, 2.45rem); }
.docforge-subtitle { margin-top: .28rem; color: var(--muted); font-size: .98rem; }
.docforge-brand { margin-bottom: .32rem; color: var(--accent-strong); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.docforge-privacy-note { max-width: 320px; margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; text-align: right; }
.docforge-capability-note { margin-top: .85rem; padding: .6rem .75rem; border: 1px solid hsl(356 72% 46% / .24); border-radius: .55rem; background: hsl(356 72% 46% / .07); color: var(--accent-strong); font-size: .82rem; }
.docforge-public .workspace { padding: 0; background: transparent; }
.docforge-public .drop-zone { min-height: 300px; display: grid; place-items: center; padding: 2.5rem 1.5rem; background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-soft); }
.docforge-public .drop-zone:hover, .docforge-public .drop-zone.drag-over { border-color: var(--accent); box-shadow: 0 10px 26px hsl(224 42% 16% / .08); }
.docforge-public .process-bar { left: 0; }
@media (max-width: 640px) {
  .docforge-public { width: min(100% - 1rem, 1140px); padding: 1rem 0 6rem; }
  .docforge-intro { display: block; padding-bottom: .75rem; }
  .docforge-privacy-note { max-width: none; margin-top: .55rem; text-align: left; }
  .docforge-public .drop-zone { min-height: 260px; padding: 2rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Minimal upload-first presentation */
.docforge-intro { align-items: center; margin-bottom: .85rem; padding-bottom: .65rem; }
.docforge-intro-copy { min-width: 0; }
.docforge-title { font-size: clamp(1.65rem, 2.6vw, 2.2rem); }
.docforge-subtitle { font-size: .94rem; }
.docforge-meta { margin-top: .7rem; color: var(--muted); font-size: .8rem; }
.docforge-public .drop-zone { min-height: 190px; padding: 2rem 1.25rem; }
.docforge-public .drop-zone-content { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.docforge-public .drop-title { font-family: var(--font-sans); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; color: var(--text); }
.docforge-public .drop-browse-btn { margin: .35rem 0 .1rem; min-width: 150px; }
.docforge-public .drop-text { order: 3; margin: 0; color: var(--muted); font-size: .88rem; }
.docforge-public .drop-hint { order: 4; margin-top: .3rem; font-size: .78rem; }
.docforge-public .drop-icon { display: none; }
@media (max-width: 640px) {
  .docforge-public .drop-zone { min-height: 170px; padding: 1.5rem 1rem; }
  .docforge-public .drop-browse-btn { min-width: 142px; }
}
