/* ==========================================================================
   File Manipulators Suite Unified Stylesheet
   Shared design system and styling for all File Manipulators tools
   ========================================================================== */

/* ==========================================================================
   1. Language Switcher Component
   ========================================================================== */
.lang-switch {
    display: inline-flex;
    background-color: var(--card);
    border: 1px solid #d1d5db;
    padding: 3px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.lang-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: none;
    background: transparent;
    font-family: inherit;
}

.lang-btn:hover {
    color: var(--text);
    background: #f1f5f9;
}

.lang-btn.active {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 119, 181, 0.3);
}

/* ==========================================================================
   2. Hub Page Layout & Cards
   ========================================================================== */
.fm-top-bar {
    display: flex;
    justify-content: flex-end; /* Removed back-to-projects, language switcher on right */
    align-items: center;
    margin-bottom: 24px;
    padding-top: 10px;
    flex-wrap: wrap;
    gap: 12px;
}

.fm-hero {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 36px auto;
}

.fm-hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
}

.fm-hero p {
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.fm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 24px;
    width: 100%;
    margin-bottom: 48px;
}

.fm-card {
    background-color: var(--card);
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    box-shadow: var(--shadow);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.fm-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.fm-card:hover {
    transform: translateY(-5px);
    border-color: #cbd5e1;
    box-shadow: 0 16px 32px rgba(0, 119, 181, 0.12);
}

.fm-card:hover::before {
    opacity: 1;
}

.fm-icon-wrapper {
    width: 54px;
    height: 54px;
    background-color: #f0f7fc;
    border: 1px solid #d0e7f9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: var(--primary);
    font-size: 1.5rem;
    transition: all 0.25s ease;
}

.fm-card:hover .fm-icon-wrapper {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: scale(1.05);
}

.fm-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.fm-card p {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.55;
    flex-grow: 1;
    margin-bottom: 18px;
}

.fm-arrow-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.2s ease;
}

.fm-card:hover .fm-arrow-link {
    color: var(--accent);
    gap: 10px;
}

.fm-badge {
    position: absolute;
    top: 18px;
    right: 18px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e0f2fe;
    color: #0369a1;
}

/* ==========================================================================
   3. Shared Tool Containers & Headers
   ========================================================================== */
.tool-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-top: 10px;
    flex-wrap: wrap;
    gap: 12px;
}

.tool-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.tool-back-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateX(-3px);
}

.tool-switch-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 6px 12px;
    background: #f0f7fc;
    border: 1px solid #c8e1f5;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.tool-switch-link:hover {
    background: #e0f0fa;
}

.tool-container {
    background: var(--card);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #e5e7eb;
    margin-bottom: 40px;
}

.tool-title-section {
    text-align: center;
    margin-bottom: 28px;
}

.tool-title-section h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 8px;
}

.tool-title-section p {
    color: var(--muted);
    font-size: 1rem;
    margin: 0;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecfdf5;
    color: #065f46;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 10px;
    border: 1px solid #a7f3d0;
}

/* ==========================================================================
   4. Shared Drag & Drop Upload Zone
   ========================================================================== */
.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 34px 20px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: 24px;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: #f0f7fc;
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.dropzone-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.dropzone-subtext {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ==========================================================================
   5. Controls, Sliders & Options Bars
   ========================================================================== */
.controls-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}

.control-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.compression-badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.slider-container input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}

.slider-endpoints {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 6px;
    padding: 0 2px;
}

.slider-endpoints span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.control-label-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.control-label-row label i,
.option-item label i,
.setting-item label i,
.filename-control i {
    color: var(--primary);
}

.slider-hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.options-bar,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 24px;
}

.option-item,
.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-item label,
.setting-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.direction-icons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    color: var(--muted);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
    margin-left: auto;
}

.direction-icons .icon-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.direction-icons .icon-item.active {
    opacity: 1;
    color: var(--primary);
    background: #e0f2fe;
    font-weight: 700;
}

.direction-icons .icon-sep {
    color: #cbd5e1;
    font-size: 0.72rem;
    user-select: none;
}

.option-item select,
.option-item input[type="text"],
.setting-item select,
.setting-item input[type="number"],
.setting-item input[type="color"] {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}

.setting-item input[type="color"] {
    height: 38px;
    cursor: pointer;
    padding: 2px 4px;
}

/* ==========================================================================
   6. Progress Bars & Action Buttons
   ========================================================================== */
.progress-bar-wrap {
    width: 100%;
    background: #e2e8f0;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
    display: none;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #10b981);
    width: 0%;
    transition: width 0.2s ease;
}

.action-buttons,
.bulk-buttons-wrap {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.bulk-buttons-wrap {
    justify-content: flex-start;
}

.bulk-buttons-stacked {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    width: 100%;
}

.bulk-buttons-stacked .btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-zip {
    background: #10b981 !important;
    border-color: #10b981 !important;
    color: #ffffff !important;
    min-width: 180px;
}

.btn-zip:hover {
    background: #059669 !important;
}

.btn-bulk-separate {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    min-width: 180px;
}

.btn-bulk-separate:hover {
    background: var(--accent) !important;
}

.convert-btn-wrapper {
    margin-top: 16px;
    margin-bottom: 24px;
}

.btn-convert,
.btn-download-joined {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-convert:hover:not(:disabled),
.btn-download-joined:hover {
    background: var(--accent);
}

.btn-convert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   7. Output Grids & Tool Results
   ========================================================================== */
.image-grid,
.pdf-grid,
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
    gap: 18px;
    margin-top: 20px;
}

.image-card,
.pdf-card,
.page-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    background: var(--card);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-card:hover,
.pdf-card:hover,
.page-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.image-card-preview,
.pdf-card-preview,
.page-card-img {
    width: 100%;
    height: 165px;
    object-fit: contain;
    background-color: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #eef2f6;
}

.image-card-title,
.pdf-card-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
    color: var(--text);
}

.page-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.page-badge {
    background: #f1f5f9;
    color: #334155;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.image-card-stats,
.pdf-card-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    color: var(--muted);
}

.stat-highlight {
    color: #10b981;
    font-weight: 700;
}

.saved-pill {
    align-self: flex-start;
    background: #ecfdf5;
    color: #047857;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
    border: 1px solid #a7f3d0;
    margin-top: 4px;
}

.btn-card-download,
.btn-page-download {
    padding: 8px 12px;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

/* ==========================================================================
   8. Image to PDF Reordering & Previews
   ========================================================================== */
.preview-section {
    margin-bottom: 24px;
}

.preview-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-section-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.clear-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.clear-btn:hover {
    background: #fee2e2;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fbfcfe;
}

.image-tile {
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.image-tile img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 6px;
}

.image-tile-name {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
    margin-bottom: 6px;
}

.btn-tile-download {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: #f0f7fc;
    border: 1px solid #c8e1f5;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.btn-tile-download:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.image-tile-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
}

.tile-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tile-remove-btn:hover {
    background: #dc2626;
}

/* ==========================================================================
   9. Photo Joiner Canvas & Arranger
   ========================================================================== */
.arrange-section {
    margin-bottom: 28px;
}

.arrange-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.arrange-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    min-height: 100px;
    padding: 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #fbfcfe;
}

.image-item {
    position: relative;
    width: 145px;
    background: #ffffff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.image-number-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    z-index: 2;
}

.image-item img {
    width: 100%;
    height: 105px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.item-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.move-btn-row {
    display: flex;
    gap: 6px;
    width: 100%;
}

.btn-action {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    padding: 6px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    transition: background 0.15s;
    font-family: inherit;
}

.btn-action:hover:not(:disabled) {
    background: #e2e8f0;
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-delete {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
    width: 100%;
}

.btn-delete:hover:not(:disabled) {
    background: #fecaca;
}

.canvas-container {
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 16px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.preview-numbers-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.preview-number-tag {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #bae6fd;
}

@media (max-width: 640px) {
    .fm-hero h1,
    .tool-title-section h1 {
        font-size: 1.8rem;
    }
    .fm-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   10. PDF Joiner & List Drag and Drop
   ========================================================================== */
.pdf-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-list-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pdf-list-item:active {
    cursor: grabbing;
}

.pdf-list-item.dragging {
    opacity: 0.5;
    background: #e9ecef;
    border-color: var(--primary);
}

.pdf-list-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.pdf-list-drag-handle {
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: grab;
}

.pdf-list-item-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.pdf-list-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdf-list-item-size {
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 500;
    margin-right: 6px;
}

.ctrl-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    padding: 6px 9px;
    border-radius: 5px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover:not(:disabled) {
    background: #e2e8f0;
    color: var(--primary);
    border-color: #94a3b8;
}

.ctrl-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pdf-list-item-remove {
    background: none;
    border: 1px solid transparent;
    color: #ef4444;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    padding: 6px 9px;
    border-radius: 5px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pdf-list-item-remove:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.summary-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.summary-size-text {
    font-size: 0.95rem;
    color: var(--text);
}

.summary-size-text strong {
    color: var(--primary);
    font-size: 1.05rem;
}

.status-message {
    margin-top: 14px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 24px;
    word-break: break-all;
}

/* ==========================================================================
   11. Unified PDF Workspace, Toolbars, Page Cards & Modals
   ========================================================================== */
.dropzone.is-dragging {
    border-color: var(--primary) !important;
    background: #f0f7fc !important;
}

.workspace-toolbar,
.split-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.workspace-toolbar h2,
.split-toolbar h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 700;
}

.workspace-toolbar p,
.split-toolbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.toolbar-dot {
    padding: 0 5px;
    color: #cbd5e1;
}

.toolbar-actions,
.split-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* filename-control: horizontal pill — icon + label prefix, then the text input inline */
.filename-control {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filename-control:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px #d7f0fb;
}

/* Icon + label text as left prefix chip */
.filename-control > i,
.filename-control > span {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 0 8px 0 10px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.filename-control > i {
    padding-right: 0;
    font-size: 0.8rem;
}

.filename-control > span {
    padding-left: 4px;
    color: var(--muted);
}

/* Divider between prefix and input */
.filename-control > span::after {
    content: '';
    display: inline-block;
    width: 1px;
    height: 18px;
    background: #d1d5db;
    margin-left: 8px;
    flex-shrink: 0;
}

/* The filename text input — inline, no extra border */
.filename-control input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    height: 100%;
    min-width: 140px;
    padding: 0 10px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    box-sizing: border-box;
}

.button,
.btn {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 9px 18px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    box-sizing: border-box;
}

.button-primary {
    background: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary);
}

.button-primary:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 119, 181, 0.25);
}

.button-secondary {
    background: #10b981;
    color: #ffffff;
    border: 1px solid #10b981;
}

.button-secondary:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.button-danger {
    background: #ef4444;
    color: #ffffff;
    border: 1px solid #ef4444;
}

.button-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
    transform: translateY(-1px);
}

.button-quiet {
    color: #475569;
    background: #ffffff;
    border: 1px solid #cbd5e1;
}

.button-quiet:hover:not(:disabled) {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #94a3b8;
}

.button:disabled,
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none !important;
    box-shadow: none !important;
}

.status-line {
    min-height: 24px;
    padding: 8px 4px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.status-line.error {
    color: #ef4444;
    font-weight: 700;
}

.status-line.success {
    color: #10b981;
    font-weight: 700;
}

.empty-state {
    padding: 48px 20px;
    color: var(--muted);
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    margin: 16px 0 24px;
}

.empty-state i {
    font-size: 2.2rem;
    color: #94a3b8;
    margin-bottom: 8px;
    display: block;
}

.empty-state h2 {
    margin: 8px 0 4px;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 700;
}

.empty-state p {
    margin: 0;
    font-size: 0.92rem;
}

.source-group,
.split-source {
    margin-top: 24px;
}

.source-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.source-heading h3 {
    overflow: hidden;
    margin: 0;
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-heading span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

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

.page-card {
    position: relative;
    min-width: 0;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

.page-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 8px 20px rgba(0, 119, 181, 0.12);
    transform: translateY(-2px);
}

.page-card.is-selected {
    border-color: var(--primary) !important;
    background: #f0f7fc !important;
    box-shadow: 0 0 0 2px #bae6fd !important;
}

.page-card.is-dragging {
    opacity: 0.45;
}

.page-card.is-over {
    border: 2px solid var(--primary);
}

.page-card canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 0.72;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid #eef2f6;
    border-radius: 4px;
}

.page-source {
    overflow: hidden;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--source-color, #64748b);
    background: var(--source-tint, #f1f5f9);
    font-size: 0.72rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 6px;
}

.page-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding: 8px 2px 2px;
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: auto;
}

.page-number {
    font-weight: 700;
    color: var(--text);
}

.page-select-control {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 2px 6px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.page-select-control input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.page-controls {
    display: flex;
    gap: 6px;
    padding: 8px 0 2px;
}

.move-page {
    display: grid;
    flex: 1;
    place-items: center;
    min-height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: var(--primary);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.move-page:hover:not(:disabled),
.move-page:focus-visible {
    border-color: var(--primary);
    background: #f0f7fc;
    outline: none;
}

.move-page:disabled {
    color: #cbd5e1;
    background: #f8fafc;
    cursor: not-allowed;
}

.remove-page {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 5px;
    color: #94a3b8;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.remove-page:hover {
    color: #ef4444;
    background: #fee2e2;
}

.rotation-controls {
    display: flex;
    gap: 6px;
    padding-top: 8px;
}

.rotation-button {
    display: grid;
    flex: 1;
    place-items: center;
    min-height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: var(--primary);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rotation-button:hover,
.rotation-button:focus-visible {
    border-color: var(--primary);
    background: #f0f7fc;
    outline: none;
}

.rotation-button.reset {
    color: #64748b;
}

.open-crop-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 34px;
    margin-top: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: var(--primary);
    background: #ffffff;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.open-crop-button:hover,
.open-crop-button:focus-visible {
    border-color: var(--primary);
    background: #f0f7fc;
    outline: none;
}

.organizer-footer,
.rotate-footer,
.split-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 0 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 28px;
    flex-wrap: wrap;
}

.organizer-footer p,
.rotate-footer p,
.split-footer p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 500;
}

.split-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Modal Styling */
.crop-modal[hidden] {
    display: none;
}

.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.crop-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.crop-modal-panel {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(940px, 100%);
    max-height: calc(100vh - 40px);
    flex-direction: column;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.crop-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.crop-modal-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 700;
}

.crop-page-title-number {
    color: var(--primary);
}

.crop-page-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-nav,
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    color: var(--muted);
    background: #ffffff;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close {
    width: 38px;
    padding: 0;
}

.modal-nav:hover:not(:disabled),
.modal-nav:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f7fc;
    outline: none;
}

.modal-nav:disabled {
    color: #cbd5e1;
    background: #f8fafc;
    cursor: not-allowed;
}

.modal-close:hover,
.modal-close:focus-visible {
    color: #ef4444;
    background: #fee2e2;
    border-color: #fca5a5;
    outline: none;
}

.crop-gallery-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 20px auto 16px;
    width: min(96vw, 900px);
}

.crop-modal-stage {
    position: relative;
    width: min(78vw, 800px);
    max-height: 64vh;
    overflow: hidden;
    background: #f1f5f9;
    box-shadow: inset 0 0 0 1px #cbd5e1;
    border-radius: 6px;
}

.crop-modal-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.crop-modal-stage .crop-selection {
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.4);
    cursor: move;
    touch-action: none;
}

.crop-modal-stage .crop-handle {
    position: absolute;
    z-index: 3;
    width: 16px;
    height: 16px;
    border: 2.5px solid #ffffff;
    border-radius: 4px;
    background: var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.crop-modal-stage .crop-handle.nw { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-modal-stage .crop-handle.ne { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-modal-stage .crop-handle.sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-modal-stage .crop-handle.se { right: -9px; bottom: -9px; cursor: nwse-resize; }

.gallery-nav {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
}

.crop-modal-rotation-top {
    margin: 12px 20px 0;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.crop-modal-rotation-top .reset-rotation-button {
    flex-basis: auto;
    width: auto;
    padding-inline: 12px;
    color: #ef4444;
    border-color: #fca5a5;
    background: #fff5f4;
}

.crop-modal-rotation-top .reset-rotation-button:hover,
.crop-modal-rotation-top .reset-rotation-button:focus-visible {
    color: #ffffff;
    border-color: #ef4444;
    background: #ef4444;
}

.crop-modal-tools {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
}

.crop-fields-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crop-fields {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    gap: 10px;
    align-items: center;
}

.crop-fields label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.crop-fields input {
    width: 32px;
    height: 32px;
    padding: 2px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    text-align: center;
    background: #ffffff;
}

.crop-fields input:focus {
    border-color: var(--primary);
    outline: 2px solid #d7f0fb;
}

.crop-modal-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

#site-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
}

#site-toast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 680px) {
    .workspace-toolbar,
    .split-toolbar,
    .organizer-footer,
    .rotate-footer,
    .split-footer {
        align-items: stretch;
        flex-direction: column;
    }
    .toolbar-actions,
    .split-toolbar-actions,
    .split-actions {
        width: 100%;
        flex-direction: column;
    }
    .filename-control {
        width: 100%;
        box-sizing: border-box;
    }
    .toolbar-actions .button,
    .split-toolbar-actions .button,
    .split-actions .button,
    .organizer-footer .button,
    .rotate-footer .button {
        width: 100%;
    }
    .page-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* CSV Preview Table & Controls */
.csv-preview-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 20px 0;
}

.csv-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.csv-preview-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.csv-preview-title i {
    color: var(--primary);
}

.csv-table-wrapper {
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    max-height: 280px;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.csv-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.csv-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csv-table tr:nth-child(even) td {
    background: #f8fafc;
}

.csv-table tr:hover td {
    background: #f0fdf4;
}

.csv-stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Mode Switcher Tabs */
.input-mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
}

.mode-tab-btn {
    border: none;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 18px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mode-tab-btn:hover {
    color: var(--primary);
}

.mode-tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Paste Textbox Card */
.paste-box-wrap {
    background: #ffffff;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.paste-box-wrap:focus-within {
    border-color: var(--primary);
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

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

.btn-editor-action {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-editor-action:hover {
    background: #e2e8f0;
    color: var(--primary);
    border-color: #94a3b8;
}

.code-textarea {
    width: 100%;
    min-height: 180px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #1e293b;
    background: #f8fafc;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s;
}

.code-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.1);
}

/* View Mode Pills (Table vs Raw Text) */
.view-mode-tabs {
    display: inline-flex;
    gap: 4px;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 8px;
}

.view-mode-btn {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.view-mode-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Raw CSV Output Area */
.raw-csv-container {
    position: relative;
    margin-top: 10px;
}

.raw-csv-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #1e293b;
    background: #ffffff;
    resize: vertical;
    box-sizing: border-box;
    white-space: pre;
    overflow-x: auto;
}

.raw-csv-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-copy-csv {
    background: #0284c7;
    color: #ffffff;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-copy-csv:hover {
    background: #0369a1;
}

.btn-copy-csv.copied {
    background: #16a34a;
}

/* ==========================================================================
   16. Converter header group (switch link + language switcher)
   ========================================================================== */
.header-right-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.header-right-group .tool-switch-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    white-space: normal;
}

/* ==========================================================================
   17. Mobile responsiveness overrides
   Kept last so these rules win the cascade over earlier blocks.
   ========================================================================== */
@media (max-width: 767px) {
    .tool-container {
        padding: 18px 14px;
    }

    .tool-title-section {
        margin-bottom: 20px;
    }

    .tool-title-section h1 {
        font-size: 1.5rem;
        overflow-wrap: break-word;
    }

    .tool-title-section p {
        font-size: 0.95rem;
    }

    .options-bar,
    .settings-grid {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 12px;
    }

    .slider-hint {
        flex-wrap: wrap;
    }

    .tool-header-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    /* Converter / switch link rows */
    .tool-header-bar .tool-switch-link {
        text-align: center;
        white-space: normal;
    }

    /* ---- PDF joiner list: stack the action cluster on its own line ---- */
    .pdf-list-item {
        flex-wrap: wrap;
        gap: 6px 10px;
        padding: 10px 12px;
    }

    .pdf-list-item-left {
        min-width: 0;
        max-width: 100%;
    }

    .pdf-list-item-name {
        max-width: min(180px, 100%);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .pdf-list-item-right {
        margin-left: auto;
    }

    .ctrl-btn,
    .pdf-list-item-remove,
    .btn-copy-csv {
        min-height: 44px;
        min-width: 44px;
    }

    /* ---- Crop & rotate modal ---- */
    .crop-modal {
        padding: 10px;
        align-items: stretch;
    }

    .crop-modal-panel {
        width: 100%;
        max-height: calc(100vh - 20px);
    }

    .crop-modal-header {
        padding: 14px;
    }

    .crop-modal-header h2 {
        font-size: 1.05rem;
    }

    .modal-nav,
    .modal-close {
        min-height: 44px;
    }

    .modal-close {
        width: 44px;
    }

    .crop-gallery-frame {
        width: 100%;
        gap: 8px;
        margin: 14px auto 12px;
        padding: 0 8px;
        box-sizing: border-box;
    }

    .crop-modal-stage {
        width: 100%;
        max-height: 52vh;
    }

    .gallery-nav {
        flex: 0 0 44px;
    }

    .crop-modal-rotation-top {
        margin: 10px 12px 0;
    }

    .crop-modal-tools {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        padding: 0 12px 14px;
    }

    .crop-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .crop-fields label {
        justify-content: space-between;
        font-size: 0.78rem;
    }

    .crop-fields input {
        width: 52px;
        height: 40px;
        font-size: 0.9rem;
    }

    .crop-modal-actions {
        justify-content: stretch;
    }

    .crop-modal-actions .button,
    .crop-modal-actions button {
        flex: 1 1 140px;
        min-height: 44px;
    }
}

@media (max-width: 420px) {
    .crop-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .preview-number-tag {
        font-size: 11px;
    }
}

/* Ultra-low-resolution viewports (legacy feature phones / low-end TV boxes
   around 240–300px): keep option rows, mode tabs and the filename pill
   inside the viewport instead of overflowing. */
@media (max-width: 300px) {
    .option-item,
    .setting-item {
        min-width: 0;
    }

    .option-item select,
    .option-item input[type="text"],
    .setting-item select,
    .setting-item input[type="number"],
    .setting-item input[type="color"] {
        width: 100%;
        min-width: 0;
    }

    .direction-icons {
        margin-left: 0;
        flex-wrap: wrap;
        max-width: 100%;
    }

    .input-mode-tabs {
        width: 100%;
        flex-wrap: wrap;
    }

    .mode-tab-btn {
        flex: 1 1 auto;
        min-width: 0;
        padding: 10px 12px;
    }

    .filename-control input {
        min-width: 0;
    }
}




