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

svg {
    fill: none !important;
    width: auto;
    height: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #fff;
    color: #333;
    overflow-x: 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-center-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.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;
}

.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;
}

.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: bar fills left-to-right based on width, no animation */
.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: #fff;
    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: ring-wrap shrinks to bar, SVG and text fade */
.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;
}

.container {
    max-width: 1100px;
    height: calc(100vh - 81px);
    align-content: center;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Step Content */
.hero {
    padding: 40px 40px 80px;
}

.step-content {
    min-height: 400px;
    display: flex;
    justify-content: center;
}

.step-panel {
    display: none;
    width: 100%;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.step-panel.active {
    display: block;
}

.step-panel.show {
    opacity: 1;
    transform: translateY(0);
}

.step-title {
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
}

.step-description {
    font-size: 12.5px;
    color: #999;
    margin-bottom: 40px !important;
}

/* Step 1: Upload */
.upload-area {
    max-width: 400px;
    margin: 40px auto;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background: #e5554a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
}

.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;
}

.file-input {
    display: none;
}

/* Step 2: Options & Preview */
.options-container {
    max-width: 1000px;
    margin: 0 auto;
}

.options-wrapper {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 40px;
    margin-bottom: 40px;
}

.pdf-preview-section {
    display: flex;
    flex-direction: column;
}

.pdf-preview {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-preview:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    border-color: #d1d5db;
}

.pdf-preview canvas {
    max-width: 100%;
    max-height: 350px;
    width: auto;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-preview:hover canvas {
    transform: scale(1.02);
}

.preview-placeholder {
    color: #9ca3af;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.options-selection-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 28px;
}

/* Option Cards */
.option-cards {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.option-card {
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.12s ease;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.option-card:hover {
    background: #f9fafb;
}

.option-card.selected {
    background: #fff5f4;
}

/* Checkbox */
.option-check {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: transparent;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.12s ease;
}

.option-check svg {
    stroke: transparent;
    transition: all 0.12s ease;
    width: 12px;
    height: 12px;
}

.option-card:hover .option-check {
    border-color: #9ca3af;
}

.option-card.selected .option-check {
    background: #ff6154;
    border-color: #ff6154;
}

.option-card.selected .option-check svg {
    stroke: white;
}

.option-content {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.option-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1f2937;
    transition: color 0.12s ease;
}

.option-desc {
    font-size: 0.72rem;
    color: #9ca3af;
    line-height: 1.35;
    margin-top: 1px;
}

/* Floating Action Bar */
.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;
}

.floating-action-bar.hidden {
    display: none;
}

@keyframes fabSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.fab-bar-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.fab-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: white;
    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);
}

.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;
}

.fab-secondary svg {
    stroke: #9ca3af;
    transition: all 0.2s;
}

.fab-secondary:hover {
    background: #eef0f3;
}

.fab-secondary:hover svg {
    stroke: #374151;
}

.fab-divider {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    flex-shrink: 0;
    margin: 0 4px;
}

.fab-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    height: 44px;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 11px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.fab-primary-text {
    position: relative;
    z-index: 1;
}

.fab-primary-arrow {
    stroke: white;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.fab-primary:hover:not(:disabled) .fab-primary-arrow {
    transform: translateX(3px);
}

.fab-primary:hover:not(:disabled) {
    background: #e5554a;
    box-shadow: 0 4px 16px rgba(255, 97, 84, 0.4);
}

.fab-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fab-primary.loading {
    pointer-events: none;
    position: relative;
    background-color: #f3f4f6;
    box-shadow: none;
    transform: none;
}

.fab-primary.loading .fab-primary-text,
.fab-primary.loading .fab-primary-arrow {
    visibility: hidden;
}

.fab-primary.loading::after {
    content: '';
    position: absolute;
    left: 20%;
    width: 60%;
    height: 3px;
    background: #e5e7eb;
    border-radius: 3px;
}

.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;
}

@keyframes fabLoadingFill {
    0%   { width: 0%; }
    30%  { width: 30%; }
    50%  { width: 42%; }
    70%  { width: 50%; }
    85%  { width: 55%; }
    100% { width: 60%; }
}

/* Step 3: Download */
#step3 {
    max-width: 380px;
    margin: 0 auto;
    text-align: left;
}

.back-button {
    background: none;
    color: #8e96a7;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    font-weight: 500;
    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-container {
    max-width: 380px;
    margin: 0 auto;
}

/* File Result Card */
.file-result-card {
    background: none;
    border: none;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.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;
}

.file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.file-meta {
    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;
}

.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;
}

.single-file-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.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;
}

/* Download Button */
.btn-download-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 18px 32px;
    margin-bottom: 0;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-download-primary:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.35);
    transform: translateY(-1px);
}

.btn-download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Another Button */
.extract-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;
}

.extract-another-btn:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

.extract-another-btn:hover .another-btn-text {
    opacity: 0;
}

.extract-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: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    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;
}

.error-message {
    color: #d93025;
    background: #fce8e6;
    border-radius: 12px;
    padding: 16px;
    margin: 20px auto;
    display: none;
    max-width: 400px;
}

/* Responsive */
@media (max-width: 768px) {
    .options-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .pdf-preview {
        min-height: 320px;
        padding: 32px;
    }

    .pdf-preview canvas {
        max-height: 240px;
    }

    .floating-action-bar {
        bottom: 16px;
    }

    .fab-primary {
        padding: 12px 24px;
        font-size: 0.88rem;
    }
}
