/* Word to PDF - Updated Design */

.hidden {
    display: none !important;
}

.hero {
    padding: 40px 40px 80px;
}

svg {
    fill: none;
}

body {
    overflow-x: hidden;
}

body.download-active {
    height: calc(100vh - 81px);
    overflow: hidden;          /* download screen is a fixed full-viewport element —
                                  no body scroll needed (kills the stray scrollbar) */
}

/* Mobile: download content can exceed the viewport, so allow scrolling there. */
@media (max-width: 768px) {
    body.download-active {
        overflow: auto;
    }
}

body.selection-active {
    overflow-y: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-center-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-bar-container {
    width: 300px;
    height: 5px;
    background: #fff;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    position: absolute;
    height: 100%;
    background: #ff6154;
    border-radius: 2px;
    width: 40%;
    will-change: transform;
    animation: loading 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(500%); }
}

.loading-text {
    font-size: 1.05rem;
    color: #1f2937;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.loading-subtext {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
    min-height: 18px;
    margin-top: 16px;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

.loading-percent {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: #999;
    font-weight: 500;
    min-height: 18px;
    font-variant-numeric: tabular-nums;
    margin-top: 40px;
    white-space: nowrap;
}

/* Upload progress mode */
.loading-bar-container.progress-mode .loading-bar {
    animation: none;
    width: 0%;
    transition: width 0.2s ease;
}

/* Upload Overlay */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.97);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.upload-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.upload-overlay.hidden {
    display: none;
}

.upload-overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: uploadCardIn 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.upload-center-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

@keyframes uploadCardIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ring progress */
.upload-ring-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    overflow: hidden;
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.upload-ring-track {
    fill: none;
    stroke: transparent;
    stroke-width: 5;
}

.upload-ring-fill {
    fill: none;
    stroke: #ff6154;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 263.89;
    stroke-dashoffset: 263.89;
    transition: stroke-dashoffset 0.3s ease;
}

.upload-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.upload-ring-percent {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    font-variant-numeric: tabular-nums;
}

.upload-phase {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2937;
    transition: opacity 0.3s ease;
}

.upload-file-name {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #9ca3af;
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 12px;
    transition: opacity 0.3s ease;
}

/* Morphing */
.upload-overlay-card.morphing .upload-ring-wrap {
    width: 300px;
    height: 4px;
    border-radius: 2px;
}

.upload-overlay-card.morphing .upload-ring {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.upload-overlay-card.morphing .upload-ring-center {
    opacity: 0;
}

.upload-overlay-card.morphing .upload-phase,
.upload-overlay-card.morphing .upload-file-name {
    opacity: 0;
}

/* Button spinner */
.btn-spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
}

.btn-convert-main.btn-loading .btn-spinner {
    display: block;
    animation: btn-spinner 0.7s linear infinite;
}

.btn-convert-main.btn-loading .btn-arrow {
    display: none;
}

.btn-convert-main.btn-loading {
    pointer-events: none;
}

.btn-convert-main.btn-loading:disabled {
    opacity: 1;
    cursor: default;
}

.btn-convert-main.btn-loading .btn-convert-content {
    visibility: hidden;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

.container {
    background-color: transparent;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 16px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto 10px auto;
    overflow: visible;
}

/* Import-screen vertical centering — body flex column at step 1
   with auto margins on hero + container so they center as a pair.
   Matches step-based tools' rhythm for cross-tool consistency. */
body:not(.selection-active):not(.download-active) {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body:not(.selection-active):not(.download-active) .hero {
    margin-top: auto;
}
body:not(.selection-active):not(.download-active) .container {
    margin-bottom: auto;
}

/* Upload Area */
.upload-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 12px;
    flex-wrap: wrap;
}

.file-input-label {
    display: inline-block;
    padding: 16px 48px;
    background-color: #ff6154;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    text-align: center;
    flex-shrink: 0;
}

.file-input-label:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
    transform: translateY(-1px);
}

.file-input-label.drag-over {
    background-color: #e5554a;
    transform: scale(1.05);
}

.upload-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.upload-icon {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    transition: opacity 0.3s ease;
}

.file-input-label:hover .upload-icon {
    opacity: 1;
}

.file-input-label:hover .upload-text {
    opacity: 0;
    visibility: hidden;
}

input[type="file"] {
    display: none;
}

/* Selection Panel */
.selection-panel {
    margin-top: 0;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    position: fixed;
    top: 81px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 81px);
}

.selection-content {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Left side - Files Preview */
.files-preview-section {
    flex: 1;
    background: none;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow-y: auto;
    margin-right: 420px;
    box-sizing: border-box;
}

/* Large File Preview Card */
.file-preview-large {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 48px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.file-preview-large:hover {
    border-color: #ff6154;
    box-shadow: 0 8px 24px rgba(255, 97, 84, 0.12);
}

.file-preview-thumbnail {
    width: 100%;
    max-width: 180px;
    background: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: visible;
    position: relative;
}

.file-preview-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

.file-preview-details {
    width: 100%;
}

.file-preview-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    word-break: break-word;
    line-height: 1.4;
}

.file-preview-size {
    font-size: 1rem;
    color: #6b7280;
    font-weight: 500;
}

.file-change-btn {
    background: transparent;
    border: 2px solid #e5e7eb;
    color: #6b7280;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.file-change-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
}

/* Right side - Controls Panel */
.controls-panel {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    box-sizing: border-box;
    padding: 40px;
    padding-bottom: 0;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.control-section {
    margin-bottom: 24px;
}

.control-section-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.control-section-bottom {
    margin-top: auto;
}

.control-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px 0;
}

/* Option groups — one per setting (quality, comments, bookmarks, PDF/A,
   page range). Each group has a small label above either a horizontal pill
   row or a free-form text input. Pills wrap on narrower widths so the
   controls panel never overflows. Mirrors excel-to-pdf's visual language. */
.option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.option-group:last-child { margin-bottom: 0; }
.option-group-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
.option-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.option-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
    line-height: 1;
    white-space: nowrap;
}
.option-pill:hover {
    border-color: #d1d5db;
    color: #1f2937;
}
.option-pill.active {
    background: #1f2937;
    border-color: #1f2937;
    color: #fff;
}
.option-pill.active:hover {
    background: #374151;
    border-color: #374151;
}

/* Free-form text input for the page-range field, revealed only when the
   "Custom" pill is active. Validated client- and server-side; the
   [pattern] attribute keeps the picker constrained to the same character
   set the backend accepts. */
.option-text-input {
    height: 36px;
    padding: 0 12px;
    margin-top: 6px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    width: 100%;
}
.option-text-input.page-range-input-hidden {
    display: none;
}
.option-text-input::placeholder {
    color: #9ca3af;
}
.option-text-input:focus {
    border-color: #1f2937;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.08);
}
.option-text-input.invalid {
    border-color: #ef4444;
}

/* Conversion Options */
.conversion-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.conversion-option-card {
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
}

.conversion-option-card input[type="radio"] {
    display: none;
}

.conversion-option-card:hover {
    border-color: #ff6154;
    background: #fff5f4;
}

.conversion-option-card.active {
    border-color: #ff6154;
    background: #fff5f4;
}

.option-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.option-details {
    flex: 1;
    min-width: 0;
}

.option-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
}

.option-check {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: white;
    position: relative;
}

.option-check::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.2s ease;
}

.conversion-option-card.active .option-check {
    border-color: #ff6154;
    background: #ff6154;
}

.conversion-option-card.active .option-check::after {
    background: white;
}

.controls-divider {
    display: none;
}

/* Convert Button */
.btn-convert-main {
    width: 100%;
    padding: 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    background-color: #ff6154;
    color: white;
    position: relative;
}

.btn-convert-main:hover:not(:disabled) {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.btn-convert-main:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Arrow icon on the right */
.btn-arrow {
    width: 24px;
    height: 24px;
    stroke: white;
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.btn-convert-main:hover .btn-arrow {
    transform: translateX(4px);
}

.btn-convert-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.btn-convert-title {
    font-size: 1rem;
    font-weight: 700;
}

.btn-convert-desc {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 400;
}

/* Download Screen */
.download-screen {
    display: none;
    padding: 0;
    max-width: 100%;
    margin: 0;
    min-height: calc(100vh - 81px);
    background: #f5f6f8;
}

.download-screen.active {
    display: block;
}

.download-content {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 81px);
}

.pdf-preview-section {
    flex: 1;
    background: #f5f6f8;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    margin-right: 420px;
    height: calc(100vh - 81px);
    box-sizing: border-box;
}

.preview-canvas-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preview-page-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
}

.preview-page-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-number-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
}

.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Back button */
.back-button {
    background: none;
    color: #8e96a7;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    position: absolute;
    margin-top: -10px;
    left: 40px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.back-button:hover {
    background: none;
    color: #374151;
    box-shadow: none;
    transform: none;
}

.back-button svg {
    width: 18px;
    height: 18px;
    background: #f9f9f9;
    padding: 6px;
    border-radius: 8px;
    box-sizing: content-box;
    transition: background 0.15s ease;
}

.back-button:hover svg {
    background: #f0f0f0;
}

#download-files-list {
    margin-top: 50px;
    margin-bottom: 24px;
}

.single-file-card {
    background: none;
    border: none;
    border-radius: 12px;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.single-file-thumb {
    width: 68px;
    height: 82px;
    background: white;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.single-file-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.single-file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.single-file-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.single-file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.single-file-name:hover {
    background: #f0f1f3;
}

.single-file-name-base {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.single-file-name-ext {
    white-space: nowrap;
    flex-shrink: 0;
    color: #9ca3af;
    margin-left: auto;
}

.file-more-btn {
    background: #f9f9f9;
    border: none;
    border-radius: 8px;
    padding: 8px 6px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.file-more-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.single-file-info {
    font-size: 0.7rem;
    color: #9ca3af;
}

.done-button {
    background: #10b981;
    color: white;
    padding: 2px 7px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 3px;
}

.done-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
}

/* Download button */
.download-primary {
    width: 100%;
    padding: 18px 32px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-decoration: none;
}

.download-primary:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.35);
    transform: translateY(-1px);
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

/* Convert Another button */
.convert-another-btn {
    width: 100%;
    padding: 13px 32px;
    margin-top: 12px;
    background: transparent;
    color: #ff6154;
    border: 1.5px solid #ff6154;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.another-btn-text,
.another-btn-arrow {
    transition: opacity 0.25s ease;
}

.another-btn-arrow {
    position: absolute;
    opacity: 0;
}

.convert-another-btn:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

.convert-another-btn:hover .another-btn-text {
    opacity: 0;
}

.convert-another-btn:hover .another-btn-arrow {
    opacity: 1;
}

/* File More Modal */
.file-more-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    animation: modalFadeIn 0.15s ease;
}

.file-more-overlay.hidden {
    display: none !important;
}

.file-more-sheet {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: sheetSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}

.file-more-group {
    background: white;
    border-radius: 16px;
    overflow: hidden;
}

.file-more-action {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s;
}

.file-more-action:hover {
    background: #f9fafb;
}

.file-more-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-more-action-icon svg {
    color: #374151;
}

.file-more-action-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.file-more-action-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #1f2937;
}

.file-more-action-desc {
    font-size: 0.75rem;
    color: #9ca3af;
}

.file-more-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0 18px;
}

.file-more-cancel {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: white;
    color: #6b7280;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.file-more-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

/* Rename Modal */
.popup-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: modalFadeIn 0.15s ease;
}

.popup-modal-overlay.hidden {
    display: none !important;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rename-modal-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    width: 320px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.rename-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

.rename-modal-input-wrap {
    display: flex;
    align-items: center;
    background: #f5f6f8;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 16px;
    overflow: hidden;
}

.rename-modal-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    color: #1f2937;
    outline: none;
    min-width: 0;
}

.rename-modal-ext {
    padding: 12px 14px 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: #9ca3af;
    flex-shrink: 0;
}

.rename-modal-actions {
    display: flex;
    gap: 8px;
}

.rename-modal-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: #f5f6f8;
    color: #6b7280;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.rename-modal-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

.rename-modal-save {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: #1f2937;
    color: white;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.rename-modal-save:hover {
    background: #374151;
}

/* Hide elements when showing download screen */
.content-hidden {
    display: none !important;
}

.controls-panel::-webkit-scrollbar,
.files-preview-section::-webkit-scrollbar,
.pdf-preview-section::-webkit-scrollbar,
.download-actions-section::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track,
.files-preview-section::-webkit-scrollbar-track,
.pdf-preview-section::-webkit-scrollbar-track,
.download-actions-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.controls-panel::-webkit-scrollbar-thumb,
.files-preview-section::-webkit-scrollbar-thumb,
.pdf-preview-section::-webkit-scrollbar-thumb,
.download-actions-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.controls-panel::-webkit-scrollbar-thumb:hover,
.files-preview-section::-webkit-scrollbar-thumb:hover,
.pdf-preview-section::-webkit-scrollbar-thumb:hover,
.download-actions-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

@media (max-width: 1200px) {
    .controls-panel {
        width: 360px;
    }

    .files-preview-section {
        margin-right: 360px;
    }

    .download-actions-section {
        width: 380px;
        padding: 32px;
    }

    .pdf-preview-section {
        margin-right: 380px;
    }
}

@media (max-width: 968px) {
    body.selection-active {
        overflow-y: auto;
    }

    /* Reset top:81px from desktop fixed-position rule. */
    .selection-panel {
        position: relative;
        top: auto;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .selection-content {
        flex-direction: column;
        height: auto;
    }

    /* Controls panel BELOW preview (order: 2) — flipped border +
       shadow to point UP. */
    .controls-panel {
        position: relative;
        width: 100%;
        height: auto;
        top: 0;
        border-left: none;
        border-top: 2px solid #e5e7eb;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
        order: 2;
    }

    .files-preview-section {
        margin-right: 0;
        height: auto;
        order: 1;
        padding: 32px 24px;
        overflow-y: visible;
    }

    /* Hide the empty step-1 .container at step 2/3. */
    body.selection-active > .container,
    body.download-active > .container {
        display: none;
    }

    .download-screen {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .download-actions-section {
        position: relative;
        top: auto;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 2px solid #e5e7eb;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
    }

    .pdf-preview-section {
        margin-right: 0;
        padding: 100px 20px 20px 20px;
        height: auto;
        min-height: 50vh;
    }

    .back-button {
        top: 20px;
        left: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .files-preview-section {
        padding: 24px 16px 40px 16px;
        min-height: auto;
    }

    .controls-panel {
        padding: 24px 16px;
    }
}

/* Document placeholder icon */
.file-icon-large {
    position: relative;
    width: 100%;
    max-width: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon-large svg {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.06));
}

.file-icon-badge {
    position: absolute;
    bottom: 18px;
    right: -12px;
    background: #f9f9f9;
    padding: 6px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

/* ────────────────────────────────────────────────────────────────────
   Drag-and-drop, password-prompt, and shared error modal — mirrors the
   pattern in compress-pdf / split-pdf, adapted for the Office-format
   single-file flow. Locked-file detection is server-driven (no client-
   side OOXML parser), so the password prompt opens when the conversion
   API responds with an encryption error.
   ──────────────────────────────────────────────────────────────────── */

.drop-zone-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.drop-zone-overlay.active { opacity: 1; pointer-events: all; }
.dz-bg {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    box-sizing: border-box;
}
.dz-bg::before {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 16px;
    background-image:
        repeating-linear-gradient(0deg,   #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(90deg,  #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(180deg, #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(270deg, #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px);
    background-size: 2px 100%, 100% 2px, 2px 100%, 100% 2px;
    background-position: 0 0, 0 0, 100% 0, 0 100%;
    background-repeat: no-repeat;
    opacity: 0.14;
    animation: dzMarch 0.8s linear infinite;
}
@keyframes dzMarch {
    to { background-position: 0 16px, -16px 0, 100% -16px, 16px 100%; }
}
.dz-pill {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #1f2937;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 10px;
    transform: translateY(6px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.dz-pill svg {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    stroke: rgba(255, 255, 255, 0.7);
    animation: dzPulse 1.8s ease-in-out infinite;
}
.drop-zone-overlay.active .dz-pill { transform: translateY(0); opacity: 1; }
@keyframes dzPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.1); }
}

.tool-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    background: #1f2937;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 9000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.tool-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.tool-toast svg { color: rgba(255,255,255,0.6); flex-shrink: 0; }

.error-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.error-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.error-modal {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-sizing: content-box;
}
.error-modal-overlay.active .error-modal { transform: scale(1); }
.error-modal-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
}
.error-modal-icon > svg {
    width: 40px;
    height: 40px;
    stroke: #f59e0b;
    animation: errorModalPulse 0.5s ease-out;
}
@keyframes errorModalPulse {
    0%   { transform: scale(0.8); opacity: 0; }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.error-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}
.error-modal-message {
    font-size: 0.88rem;
    color: #6b7280;
    line-height: 1.4;
    margin: 0 0 20px 0;
}
.error-modal-btn {
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
}
.error-modal-btn:hover { background: #374151; }

/* Locked-file variant — same shape as compress-pdf's locked-pdf modal.
   Grey lock icon stroke + amber info badge anchored to the bottom-
   right corner; primary CTA in the actions slot is the dismiss button
   styled as secondary outline. Used for password-protected Word/Excel/
   PowerPoint files (backend can't accept the password, so the only
   action is "remove the password at source and re-upload"). */
.error-modal-icon { position: relative; }
.error-modal-overlay.locked-pdf .error-modal-icon > svg {
    stroke: #9ca3af;
}
.error-modal-icon-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
    box-sizing: content-box;
    width: 14px;
    height: 14px;
    color: #f59e0b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.error-modal-icon-badge svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    animation: none;
}
.error-modal-overlay.locked-pdf .error-modal-btn {
    background: transparent;
    color: #6b7280;
    border: 2px solid #e5e7eb;
    box-shadow: none;
}
.error-modal-overlay.locked-pdf .error-modal-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
    background: #fff5f4;
    box-shadow: none;
}

/* ============================================================
   MOBILE & TABLET OVERRIDES — added 2026-05-07
   Sidebar-style download view, so merge ≤970 full-screen recipe
   applies. Step-1 container hidden via direct-child selector.
   ============================================================ */

/* ---- Phone (≤768px) ---- */
@media (max-width: 768px) {
    /* iOS auto-zoom prevention. */
    input, textarea, select { font-size: 16px; }
    .rename-modal-input { font-size: 16px !important; }

    /* Safe-area on bottom-anchored UI for iPhone home indicator. */
    .controls-panel {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    .file-more-sheet {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Rename modal card responsive. */
    .rename-modal-card {
        width: calc(100% - 24px) !important;
        max-width: 360px;
        margin: 12px;
    }

    /* .file-preview-large overflow fix — border-box + tighter
       padding so 100% width + 48px desktop padding doesn't push
       the card past the viewport. */
    .file-preview-large {
        box-sizing: border-box;
        padding: 28px 20px;
    }

    /* File-card containment — let ellipsis truncate filenames. */
    .file-card {
        min-width: 0;
        box-sizing: border-box;
    }
}

/* ---- Tablet & narrow desktop — download view full-screen (≤970px) ---- */
@media (max-width: 970px) {
    .download-screen .pdf-preview-section { display: none !important; }
    body.download-active .hero { display: none !important; }

    .download-screen {
        background: white !important;
        min-height: 0 !important;
        height: auto !important;
    }
    .download-content {
        flex-direction: column;
        height: auto !important;
        min-height: 0 !important;
        background: white;
    }
    .download-actions-section {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        padding: 32px 20px max(32px, env(safe-area-inset-bottom)) !important;
        border: none !important;
        box-shadow: none !important;
        background: white;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        box-sizing: border-box;
        overflow: visible !important;
    }

    .download-actions-section > * {
        width: 100%;
        max-width: 480px;
        box-sizing: border-box;
    }
    .download-primary,
    #download-files-list,
    .single-file-card,
    .extract-another-btn {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Back-button aligned with the 480 column edge — padding zeroed
       so the arrow icon sits flush. */
    .back-button {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        margin: 0 auto 24px !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 480px !important;
        display: flex !important;
        justify-content: flex-start !important;
    }

    #download-files-list {
        margin-top: 0 !important;
        margin-bottom: 40px !important;
    }
    .single-file-card { margin: 0 !important; }
    .download-primary { margin-bottom: 0 !important; }
    .extract-another-btn { margin-top: 12px !important; }
}
/* Inline breadcrumb chevron used inside the locked-file message
   ("File › Info › Protect Document › Encrypt with Password"). Sized
   to nudge between words without throwing off the line height. */
.error-modal-message .path-chevron {
    width: 10px;
    height: 10px;
    vertical-align: -0.05em;
    margin: 0 1px;
    color: #9ca3af;
    flex-shrink: 0;
}

/* Password-prompt modal removed — backend never accepted the password
   so the prompt was misleading. Encrypted-file errors now surface a
   one-line "remove the password and re-upload" message via the
   regular error modal. */
/* ── HTML→PDF: "or paste HTML code" option (file upload stays default) ── */
.h2p-pane.hidden { display: none; }

/* Subtle secondary link under the upload button. */
.h2p-paste-link {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    width: fit-content; margin: 18px auto 0;
    background: none; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; color: #6b7280;
    transition: color 0.15s ease;
}
.h2p-paste-link svg { opacity: 0.75; }
.h2p-paste-link:hover { color: #ff6154; }

/* ── Code editor (paste mode) — refined dark editor surface ── */
/* Reserve static space below the editor for the floating action bar (fixed at
   bottom:24px, ~44px tall) so the FAB never overlaps the editor card. Static =
   no JS, no scroll-driven layout thrash. */
.h2p-code-pane { max-width: 780px; margin: 8px auto 0; width: 100%; padding-bottom: 100px; }

.h2p-editor {
    border-radius: 14px; overflow: hidden;
    background: #212121;                 /* matches material-darker bg */
    box-shadow: 0 24px 60px -28px rgba(16, 24, 40, 0.45), 0 2px 8px rgba(16, 24, 40, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Toolbar */
.h2p-editor-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 16px;
    background: #1b1b1b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.h2p-editor-title {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: #ff8a7e;
}
.h2p-editor-title svg { color: #ff6154; }
.h2p-editor-meta { display: inline-flex; align-items: center; gap: 14px; }
.h2p-editor-count {
    font-size: 12px; color: #7f8a96; font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.h2p-editor-clear {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255, 255, 255, 0.06); border: none; cursor: pointer;
    color: #aab3bd; font-size: 12px; font-weight: 600;
    padding: 5px 10px; border-radius: 7px;
    transition: all 0.15s ease;
}
.h2p-editor-clear:hover { background: rgba(255, 97, 84, 0.16); color: #ff8a7e; }

/* Fullscreen toggle button (matches the clear chip styling). */
.h2p-editor-fs {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 28px; padding: 0;
    background: rgba(255, 255, 255, 0.06); border: none; border-radius: 7px;
    color: #aab3bd; cursor: pointer; transition: all 0.15s ease;
}
.h2p-editor-fs:hover { background: rgba(255, 97, 84, 0.16); color: #ff8a7e; }

/* Fullscreen editor state — fixed, fills the viewport above everything. */
.h2p-editor.h2p-fs-active {
    position: fixed;
    inset: 0;
    z-index: 9998;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}
.h2p-editor.h2p-fs-active .CodeMirror {
    flex: 1;
    height: auto !important;               /* fill remaining height below the bar */
}
body.h2p-fs-lock { overflow: hidden; }     /* lock page scroll while fullscreen */
/* Hide the FAB (Back / Convert) while the editor is fullscreen — exit fullscreen
   to access it. */
body.h2p-fs-lock .h2p-fab.floating-action-bar { display: none; }

/* CodeMirror surface */
.h2p-editor .CodeMirror {
    height: 360px;
    font-size: 13.5px; line-height: 1.65;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 8px 0;
}
.h2p-editor .CodeMirror-gutters { background: #1f1f1f; border-right: 1px solid rgba(255,255,255,0.05); }
.h2p-editor .CodeMirror-linenumber { color: #5a6470; }
.h2p-editor .CodeMirror-cursor { border-left: 2px solid #ff6154; }
.h2p-editor .CodeMirror-selected { background: rgba(255, 97, 84, 0.18) !important; }
.h2p-editor .CodeMirror-placeholder { color: #5a6470 !important; }

/* Native webkit scrollbar styled like the site's dropdowns (grayscale-pdf),
   which naturally shows both ends and respects the container's rounded edges.
   The CodeMirror viewport is rounded + clipped so the bar sits inside the
   corners. Vertical only — lineWrapping means no horizontal overflow. */
.h2p-editor .CodeMirror-vscrollbar { overflow-x: hidden !important; }
.h2p-editor .CodeMirror-hscrollbar { display: none !important; }
.h2p-editor .CodeMirror-vscrollbar::-webkit-scrollbar,
.h2p-editor .CodeMirror-scroll::-webkit-scrollbar {
    width: 8px; height: 0;
}
.h2p-editor .CodeMirror-vscrollbar::-webkit-scrollbar-track,
.h2p-editor .CodeMirror-scroll::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;                          /* keeps BOTH ends clear of the corners */
}
.h2p-editor .CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
.h2p-editor .CodeMirror-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    /* Minor right inset — a transparent right border clips the visible thumb
       inward, creating a small gap from the right edge. */
    border-right: 2px solid transparent;
    background-clip: padding-box;
}
.h2p-editor .CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover,
.h2p-editor .CodeMirror-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.34);
    background-clip: padding-box;
}
.h2p-editor .CodeMirror-vscrollbar::-webkit-scrollbar-button,
.h2p-editor .CodeMirror-scroll::-webkit-scrollbar-button {
    display: none; height: 0; width: 0;
}

.h2p-editor.h2p-shake { animation: h2pShake 0.45s cubic-bezier(0.36,0.07,0.19,0.97); }
@keyframes h2pShake {
    10%,90% { transform: translateX(-1px); } 20%,80% { transform: translateX(2px); }
    30%,50%,70% { transform: translateX(-4px); } 40%,60% { transform: translateX(4px); }
}

/* ── Floating action bar (mirrors merge-pdf's FAB) ── */
.h2p-fab.floating-action-bar {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: flex; flex-direction: column; align-items: center;
    animation: fabSlideUp 0.4s cubic-bezier(0.32, 0.72, 0, 1) both;
}
.h2p-fab .fab-bar-row { display: flex; align-items: center; }
.h2p-fab .fab-inner {
    display: flex; align-items: center; gap: 6px;
    padding: 6px;
    background: #fff; border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.h2p-fab .fab-secondary {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    background: #f5f6f8; color: #6b7280;
    border: none; border-radius: 11px; cursor: pointer;
    transition: all 0.2s ease; flex-shrink: 0;
}
.h2p-fab .fab-secondary:hover { background: #ececf0; color: #ff6154; }
.h2p-fab .fab-divider { width: 1px; height: 24px; background: #d1d5db; flex-shrink: 0; margin: 0 4px; }
.h2p-fab .fab-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 22px; height: 44px;
    background: #ff6154; color: #fff;
    border: none; border-radius: 11px;
    font-size: 0.95rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; letter-spacing: 0.01em; flex-shrink: 0;
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}
.h2p-fab .fab-primary-arrow { transition: transform 0.2s ease; }
.h2p-fab .fab-primary:hover { background: #ff4f40; box-shadow: 0 8px 22px -6px rgba(255, 97, 84, 0.7); }
.h2p-fab .fab-primary:hover .fab-primary-arrow { transform: translateX(3px); }
.h2p-fab .fab-primary:active { transform: scale(0.97); }

/* On-click loading line (identical to merge-pdf's FAB button). The button text
   hides and a coral line fills a grey track inside the button. */
.h2p-fab .fab-primary.loading,
.h2p-fab .fab-primary.loading-done {
    pointer-events: none;
    position: relative;
    background-color: #f3f4f6;
    box-shadow: none;
    transform: none;
}
.h2p-fab .fab-primary.loading .fab-primary-text,
.h2p-fab .fab-primary.loading .fab-primary-arrow,
.h2p-fab .fab-primary.loading-done .fab-primary-text,
.h2p-fab .fab-primary.loading-done .fab-primary-arrow {
    visibility: hidden;
}
.h2p-fab .fab-primary.loading::after,
.h2p-fab .fab-primary.loading-done::after {
    content: '';
    position: absolute;
    left: 20%;
    width: 60%;
    height: 3px;
    background: #e5e7eb;
    border-radius: 3px;
}
.h2p-fab .fab-primary.loading::before {
    content: '';
    position: absolute;
    left: 20%;
    width: 0%;
    height: 3px;
    background: #ff6154;
    z-index: 1;
    border-radius: 3px;
    animation: fabLoadingFill 2s ease-out forwards;
}
.h2p-fab .fab-primary.loading-done::before {
    content: '';
    position: absolute;
    left: 20%;
    width: 60%;
    height: 3px;
    background: #ff6154;
    z-index: 1;
    border-radius: 3px;
}
@keyframes fabLoadingFill {
    0%   { width: 0%; }
    30%  { width: 30%; }
    50%  { width: 42%; }
    70%  { width: 50%; }
    85%  { width: 55%; }
    100% { width: 60%; }
}

@keyframes fabSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 640px) {
    .h2p-editor .CodeMirror { height: 300px; }
    .h2p-fab.floating-action-bar { bottom: 16px; }
    .h2p-fab .fab-primary { padding: 11px 18px; font-size: 0.88rem; }
}
