/* =========================================================
   8XTools — Universal responsive mobile polish
   Applied to every tool page. Desktop is left untouched.
   ========================================================= */

@media (max-width: 700px) {
  *, *::before, *::after { box-sizing: border-box; }

  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body {
    margin: 0 !important;
    -webkit-text-size-adjust: 100%;
  }

  img, canvas, video {
    max-width: 100% !important;
  }

  h1 {
    margin: 20px 0 8px !important;
    font-size: clamp(27px, 8vw, 36px) !important;
    line-height: 1.15 !important;
  }

  h2 {
    font-size: clamp(22px, 6.5vw, 30px) !important;
    line-height: 1.2 !important;
  }

  .subtitle {
    width: calc(100% - 32px) !important;
    max-width: 620px !important;
    margin: 8px auto 22px !important;
    line-height: 1.45 !important;
    font-size: 14px !important;
  }

  /* Common page containers */
  .page,
  .main,
  .workspace,
  .ic-wrap,
  .upload-area,
  .split-upload,
  .pdf-container,
  .top-bar,
  #results,
  .seo-info,
  .seo {
    width: calc(100% - 24px) !important;
    max-width: 680px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Tool workspaces become one focused mobile column */
  .workspace,
  .ic-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  .panel,
  .card,
  .tool-card,
  .ic-card,
  .settings-panel,
  .output-panel {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 16px !important;
  }

  .panel,
  .card {
    padding: 16px !important;
  }

  .panel-title,
  .card-title {
    font-size: 18px !important;
    margin-bottom: 12px !important;
  }

  /* Upload areas */
  .upload-area,
  .drop,
  .upload-box,
  .ic-upload {
    width: 100% !important;
    max-width: 100% !important;
  }

  .drop,
  .upload-area {
    margin-top: 10px !important;
  }

  .drop {
    min-height: 250px !important;
    padding: 20px 14px !important;
  }

  .upload-row,
  .button-row {
    width: 100% !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  .choose-pdf,
  .choose-image,
  .choose-button,
  .ic-btn,
  .primary,
  .crop-button,
  .resize-button,
  .download-button,
  .pdf-convert-button,
  .settings-split-button,
  #splitButton,
  .compress-btn,
  .convert-button {
    min-height: 46px !important;
    width: min(100%, 280px) !important;
  }

  /* Generic preview/result areas */
  .preview-area,
  .preview-box,
  .crop-area,
  .output-preview,
  .pdf-upload-box,
  .ic-preview,
  .ic-result,
  .file-preview,
  .result {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .preview-area,
  .preview-box,
  .output-preview {
    min-height: 280px !important;
  }

  .crop-area {
    min-height: 300px !important;
    max-height: none !important;
  }

  /* PDF/image thumbnail grids */
  .preview-grid,
  .pdf-preview-grid,
  .result-grid,
  #preview,
  .ic-grid,
  .ratio-grid,
  .mode-grid,
  .settings-grid,
  .preset-grid,
  .levels,
  .orientation-options,
  .orientation-box {
    gap: 9px !important;
  }

  .preview-grid,
  .pdf-preview-grid,
  .result-grid,
  #preview {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .image-card,
  .pdf-card,
  .page-card,
  .result-card {
    min-width: 0 !important;
    width: 100% !important;
  }

  .image-card img {
    height: 145px !important;
  }

  .page-card canvas {
    height: 155px !important;
    max-width: 100% !important;
  }

  .pdf-preview-grid .pdf-card,
  .result-grid .result-card {
    min-height: 190px !important;
  }

  /* Settings: two compact choices across */
  .ratio-grid,
  .mode-grid,
  .settings-grid,
  .preset-grid,
  .orientation-options,
  .orientation-box {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .ratio-button,
  .mode-option,
  .setting-option,
  .preset,
  .orientation-card,
  .orientation-option,
  .level {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 68px !important;
    padding: 10px !important;
  }

  .dimension-row,
  .custom-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .dimension-row input,
  .unit-select,
  .input-group input,
  .target-controls input,
  .target-controls select,
  #pageInput,
  #customPages {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Merge PDF: iLovePDF-like vertical file cards */
  .top-bar {
    justify-content: center !important;
    margin-bottom: 12px !important;
  }

  .pdf-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 16px !important;
  }

  .pdf-item,
  .pdf-container .pdf-card,
  .pdf-container .add-card,
  .add-card {
    width: min(100%, 300px) !important;
  }

  .pdf-container .pdf-card,
  .pdf-container .add-card {
    height: 280px !important;
  }

  .pdf-card canvas {
    max-height: 245px !important;
  }

  .pdf-name {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .bottom-bar {
    width: calc(100% - 24px) !important;
    max-width: 680px !important;
    margin: 20px auto 30px !important;
  }

  .merge-button {
    width: 100% !important;
    max-width: 360px !important;
    min-height: 50px !important;
  }

  /* Compress / rotate: one clean column */
  .levels,
  .mode-list,
  .rotate-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }

  .level {
    display: flex !important;
    align-items: center !important;
  }

  .level:last-child {
    grid-column: 1 / -1;
  }

  .rotate-option {
    min-height: 82px !important;
  }

  .notice,
  .help,
  .info-box,
  .instructions {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  /* PDF to JPG */
  .pdf-details,
  .result-header {
    width: 100% !important;
    min-width: 0 !important;
  }

  .result-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }

  .download-all {
    width: auto !important;
    min-height: 40px !important;
    padding: 8px 12px !important;
  }

  /* Image compressor */
  .ic-wrap {
    padding-bottom: 30px !important;
  }

  .ic-card {
    padding: 16px !important;
  }

  .ic-upload {
    padding: 18px 12px !important;
  }

  .ic-preview {
    min-height: 260px !important;
  }

  .ic-settings {
    width: 100% !important;
  }

  /* SEO text stays readable and compact */
  .seo-info,
  .seo,
  .ic-wrap > section:last-child {
    padding: 0 4px !important;
    font-size: 13px !important;
    line-height: 1.65 !important;
  }

  .seo-info h2,
  .seo h2,
  .ic-wrap > section:last-child h2 {
    font-size: 20px !important;
  }
}

@media (max-width: 430px) {
  h1 { font-size: 29px !important; }
  h2 { font-size: 22px !important; }

  .page,
  .main,
  .workspace,
  .ic-wrap,
  .upload-area,
  .split-upload,
  .pdf-container,
  .top-bar,
  #results,
  .seo-info,
  .seo {
    width: calc(100% - 18px) !important;
  }

  .preview-grid,
  .pdf-preview-grid,
  .result-grid,
  #preview {
    gap: 7px !important;
  }

  .image-card img { height: 125px !important; }
  .page-card canvas { height: 140px !important; }

  .ratio-grid,
  .mode-grid,
  .settings-grid,
  .preset-grid,
  .orientation-options,
  .orientation-box,
  .levels,
  .mode-list,
  .rotate-buttons {
    gap: 7px !important;
  }

  .ratio-button,
  .mode-option,
  .setting-option,
  .preset,
  .orientation-card,
  .orientation-option,
  .level {
    min-height: 62px !important;
    font-size: 12px !important;
  }
}


/* =========================================================
   8XTools FINAL RESPONSIVE RULES
   Mobile: preview panels hidden
   Tablet/Desktop: preview panels visible
   ========================================================= */

/* Keep preview/workspace visible by default */
.preview-panel,
.preview-container,
.preview-area,
.pdf-preview,
.image-preview,
.preview-section {
  display: block;
}

/* Phones: hide large preview panels to keep the UI compact */
@media (max-width: 767px) {
  .preview-panel,
  .preview-container,
  .preview-area,
  .pdf-preview,
  .image-preview,
  .preview-section {
    display: none !important;
  }

  /* Preserve small file/image thumbnails/cards */
  .file-preview,
  .file-card,
  .thumbnail,
  .thumb,
  .image-card,
  .pdf-card {
    display: flex;
  }

  /* Prevent horizontal overflow */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  img,
  canvas,
  video,
  iframe {
    max-width: 100%;
  }

  .container,
  .tool-container,
  .page-container,
  .main-container {
    width: 100%;
    max-width: 100%;
  }
}

/* Tablets: restore preview panels */
@media (min-width: 768px) {
  .preview-panel,
  .preview-container,
  .preview-area,
  .pdf-preview,
  .image-preview,
  .preview-section {
    display: block !important;
  }
}

/* Desktop: preserve full workspace */
@media (min-width: 1024px) {
  .preview-panel,
  .preview-container,
  .preview-area,
  .pdf-preview,
  .image-preview,
  .preview-section {
    display: block !important;
  }
}


/* =========================================================
   8XTools FINAL v10 — mobile preview policy
   Phone: hide LARGE preview panels
   Tablet/Desktop: keep previews visible
   ========================================================= */

@media (max-width: 767px) {

  /* PDF → JPG: hide the dedicated PDF Preview panel */
  .workspace > .panel:has(#pdf-preview-area) {
    display: none !important;
  }

  /* Split PDF: hide the large PDF preview panel */
  .workspace > .panel:has(#preview) {
    display: none !important;
  }

  /* Resize Image: hide the large image preview panel */
  .workspace > .panel:has(#previewArea),
  .workspace > .panel:has(#outputPreview) {
    display: none !important;
  }

  /* Crop Image: hide the large output preview area */
  .workspace > .panel:has(.output-preview),
  .crop-area {
    display: none !important;
  }

  /* Image Compressor: hide the large preview area */
  .ic-preview {
    display: none !important;
  }

  /* Rotate PDF: hide large preview box, keep controls */
  .preview-box,
  #filePreview {
    display: none !important;
  }

  /* Generic large preview containers */
  .preview-area,
  .preview-box,
  .output-preview,
  .preview-section,
  .pdf-preview {
    display: none !important;
  }

  /* Do NOT hide file cards / selected-image thumbnails */
  .file-card,
  .file-preview,
  .image-card,
  .pdf-card,
  .pdf-item,
  .selected-preview {
    display: flex;
  }
}

/* Tablet and desktop: restore all preview/workspace panels */
@media (min-width: 768px) {
  .workspace > .panel:has(#pdf-preview-area),
  .workspace > .panel:has(#preview),
  .workspace > .panel:has(#previewArea),
  .workspace > .panel:has(#outputPreview),
  .preview-box,
  #filePreview,
  .ic-preview,
  .preview-area,
  .output-preview,
  .preview-section,
  .pdf-preview {
    display: block !important;
  }
}


/* =========================================================
   8XTools FINAL v11
   MOBILE ONLY: hide passive preview panels/results.
   TABLET + DESKTOP: unchanged.
   ROTATE PDF: keep rotated preview only.
   ========================================================= */

@media (max-width: 767px) {

  /* PDF -> JPG: no PDF page preview and no converted-image preview.
     Download controls remain available. */
  #pdf-preview-area,
  .pdf-preview-grid {
    display: none !important;
  }

  #results .result-card img,
  #results .result-grid img {
    display: none !important;
  }

  /* Split PDF: no page-preview grid. Download results remain. */
  #preview.preview-grid {
    display: none !important;
  }

  /* JPG -> PDF: hide selected-image preview grid.
     File selection and conversion controls remain. */
  #preview {
    display: none !important;
  }

  /* Resize Image: hide original + resized preview areas.
     File information, dimensions and Resize button remain. */
  #previewArea,
  #outputPreview {
    display: none !important;
  }

  /* Image Compressor: hide original image preview.
     Compression controls + download/result remain. */
  .ic-preview {
    display: none !important;
  }

  /* Compress PDF: hide the uploaded PDF preview. */
  #pdfPreview {
    display: none !important;
  }

  /* Merge PDF: hide rendered PDF page canvases.
     Keep PDF file cards/names, Add PDF and Merge PDF controls. */
  #pdfContainer .pdf-item canvas {
    display: none !important;
  }

  /* Crop Image:
     Keep the interactive crop canvas because the user must see the
     image to select the crop area. Hide the passive result preview. */
  #outputPreview {
    display: none !important;
  }

  /* Rotate PDF:
     Hide the original uploaded-PDF preview, but KEEP the rotated
     preview (.preview-box / #rotatedCanvas) as requested. */
  #filePreview {
    display: none !important;
  }

  /* Generic passive preview/result panels used by older tool pages. */
  .preview-panel,
  .preview-container,
  .preview-area:not(#cropArea),
  .image-preview,
  .output-preview,
  .preview-section {
    display: none !important;
  }

  /* Don't hide buttons, settings or download/result information. */
  .result,
  .ic-result,
  .download,
  .download-all,
  .primary,
  button {
    visibility: visible;
  }
}

/* =========================================================
   TABLET + DESKTOP
   No mobile preview changes apply at these widths.
   ========================================================= */
@media (min-width: 768px) {
  #pdf-preview-area,
  .pdf-preview-grid,
  #results .result-card img,
  #preview.preview-grid,
  #previewArea,
  #outputPreview,
  .ic-preview,
  #pdfPreview,
  #pdfContainer .pdf-item canvas,
  #filePreview,
  .preview-panel,
  .preview-container,
  .preview-area,
  .image-preview,
  .output-preview,
  .preview-section {
    /* Do not force display here; original page CSS controls it. */
  }
}


/* =========================================================
   8XTools FINAL v12 — Mobile clean workflow
   MOBILE ONLY. Tablet/Desktop are intentionally untouched.

   Mobile flow:
   File name → Settings → Action/Download
   No passive/live result previews.
   Rotate PDF keeps ONLY its rotated preview.
   ========================================================= */

@media (max-width: 767px) {

  /* ---------- GENERAL ---------- */
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Hide generic passive preview/output areas on phones. */
  .preview-area,
  .output-preview,
  .image-preview,
  .preview-section,
  .preview-panel,
  .preview-container {
    display: none !important;
  }

  /* ---------- PDF TO JPG ---------- */
  /* No page preview. */
  #pdf-preview-area,
  .pdf-preview-grid {
    display: none !important;
  }

  /* Settings first, then generated file names/downloads. */
  .workspace {
    display: flex !important;
    flex-direction: column !important;
  }

  .workspace > .settings-panel {
    order: 1 !important;
  }

  .workspace > .panel:has(#results) {
    order: 2 !important;
  }

  /* Converted images themselves are never shown on mobile. */
  #results img,
  #results canvas {
    display: none !important;
  }

  /* Keep generated file names + download buttons. */
  #results .result-card {
    min-height: 0 !important;
    padding: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }

  #results .result-card p,
  #results .result-name {
    margin: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #results .result-card button,
  #results .download-link {
    flex: 0 0 auto !important;
  }

  /* Download All stays immediately after settings. */
  .download-all {
    width: 100% !important;
    margin-top: 8px !important;
  }

  /* ---------- SPLIT PDF ---------- */
  #preview.preview-grid,
  #preview {
    display: none !important;
  }

  /* Settings before generated split files. */
  .workspace > .panel:has(#results) {
    order: 2 !important;
  }

  .workspace > .settings-panel {
    order: 1 !important;
  }

  #results canvas,
  #results img {
    display: none !important;
  }

  .result-icon {
    display: none !important;
  }

  .result-card {
    min-height: 0 !important;
    padding: 12px !important;
  }

  .download-link,
  #downloadAll {
    min-height: 44px !important;
  }

  /* ---------- JPG TO PDF ---------- */
  /* Keep file cards/names, but remove image thumbnails. */
  #preview img,
  #preview canvas {
    display: none !important;
  }

  #preview {
    display: block !important;
    grid-template-columns: 1fr !important;
  }

  #preview .image-card {
    min-height: 0 !important;
    padding: 12px !important;
  }

  #preview .image-card img,
  #preview .preview-image,
  #preview .remove-button + img {
    display: none !important;
  }

  /* Hide the live-preview heading/empty-preview message. */
  .preview-title {
    display: none !important;
  }

  #preview .empty {
    display: none !important;
  }

  /* ---------- MERGE PDF ---------- */
  /* No rendered PDF thumbnails on phones. */
  #pdfContainer canvas {
    display: none !important;
  }

  .pdf-card {
    min-height: 54px !important;
    height: 54px !important;
  }

  .pdf-card canvas {
    display: none !important;
  }

  .page-count {
    display: none !important;
  }

  .pdf-name {
    max-width: calc(100vw - 120px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Keep the main action close to the file list. */
  .bottom-bar {
    position: sticky !important;
    bottom: 8px !important;
    z-index: 20 !important;
    padding: 8px 0 !important;
    background: rgba(248,250,255,.94) !important;
    backdrop-filter: blur(8px) !important;
  }

  .merge-button {
    width: 100% !important;
    min-height: 50px !important;
  }

  /* ---------- RESIZE IMAGE ---------- */
  /* No original preview and no resized-image preview. */
  #previewArea,
  #outputPreview {
    display: none !important;
  }

  .image-info-icon {
    display: none !important;
  }

  /* Output/action card follows settings; keep action + download. */
  .workspace > .output-panel {
    display: block !important;
  }

  .output-panel .panel-title {
    display: none !important;
  }

  .output-panel .output-info {
    margin-top: 0 !important;
  }

  .resize-button,
  .download-button {
    width: 100% !important;
    min-height: 48px !important;
    margin-top: 10px !important;
  }

  /* ---------- IMAGE COMPRESSOR ---------- */
  .ic-preview {
    display: none !important;
  }

  .ic-grid {
    display: block !important;
  }

  .ic-settings {
    width: 100% !important;
  }

  .ic-download {
    width: 100% !important;
    min-height: 48px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ---------- COMPRESS PDF ---------- */
  #pdfPreview {
    display: none !important;
  }

  #fileBox {
    display: flex !important;
  }

  /* Don't show duplicate empty preview messaging. */
  #emptyMessage {
    display: none !important;
  }

  /* Download remains inside the compact result card. */
  #result {
    margin-top: 12px !important;
  }

  #downloadBtn {
    width: 100% !important;
    min-height: 48px !important;
  }

  /* ---------- ROTATE PDF ---------- */
  /* Original preview hidden, but the rotated result preview stays visible. */
  #filePreview {
    display: none !important;
  }

  .preview-box {
    display: flex !important;
  }

  /* ---------- CROP IMAGE ---------- */
  /*
     Crop needs an interactive source image so the user can select
     the crop area. Only the generated output preview is removed.
  */
  #outputPreview {
    display: none !important;
  }

  #download {
    width: 100% !important;
    min-height: 48px !important;
    align-items: center !important;
    justify-content: center !important;
  }
}


/* =========================================================
   8XTools FINAL v13 — MERGE PDF mobile
   Mobile only: filename rows, no live PDF thumbnail/preview.
   Tablet/Desktop are unchanged.
   ========================================================= */

@media (max-width: 767px) {

  /* Compact selected-PDF list */
  #pdfContainer {
    width: calc(100% - 28px) !important;
    max-width: 680px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  #pdfContainer .pdf-item {
    width: 100% !important;
    min-height: 64px !important;
    height: 64px !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    box-sizing: border-box !important;

    display: grid !important;
    grid-template-columns: 28px minmax(0, 1fr) 38px !important;
    grid-template-rows: 28px 22px !important;
    grid-template-areas:
      "check name remove"
      "check pages remove" !important;
    align-items: center !important;
    gap: 0 8px !important;

    background: #fff !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 14px rgba(0,0,0,.08) !important;
  }

  /* Checkbox becomes a normal grid item */
  #pdfContainer .pdf-item > .checkbox {
    position: static !important;
    grid-area: check !important;
    width: 24px !important;
    height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #pdfContainer .pdf-item > .checkbox input {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
  }

  /* Remove the thumbnail/card completely, but keep its X button */
  #pdfContainer .pdf-item > .pdf-card {
    display: contents !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  #pdfContainer .pdf-item > .pdf-card canvas {
    display: none !important;
  }

  #pdfContainer .pdf-item > .pdf-card .remove-button {
    position: static !important;
    grid-area: remove !important;
    width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    border-radius: 50% !important;
    font-size: 17px !important;
    justify-self: center !important;
    align-self: center !important;
  }

  /* Only the filename + page count remain */
  #pdfContainer .pdf-item > .pdf-name {
    grid-area: name !important;
    min-width: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;

    font-size: 13px !important;
    line-height: 18px !important;
    text-align: left !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #pdfContainer .pdf-item > .page-count {
    grid-area: pages !important;
    margin: 0 !important;
    padding: 0 !important;

    font-size: 11px !important;
    line-height: 16px !important;
    text-align: left !important;
    color: #777 !important;
  }

  /* Add PDF card stays compact */
  #pdfContainer > .add-card {
    width: 100% !important;
    max-width: none !important;
    height: 74px !important;
    min-height: 74px !important;
    margin: 2px 0 0 !important;
    padding: 8px 16px !important;
    box-sizing: border-box !important;
    border-radius: 14px !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 12px !important;
  }

  #pdfContainer > .add-card .add-icon {
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    flex: 0 0 40px !important;
  }

  #pdfContainer > .add-card p {
    margin: 0 !important;
    text-align: left !important;
    font-size: 12px !important;
    line-height: 16px !important;
  }

  /* Keep Merge action immediately below the list */
  .bottom-bar {
    width: calc(100% - 28px) !important;
    max-width: 680px !important;
    margin: 12px auto 18px !important;
    padding: 0 !important;
  }

  .merge-button {
    width: 100% !important;
    min-height: 48px !important;
    padding: 12px 18px !important;
    border-radius: 12px !important;
  }
}


/* =========================================================
   8XTools FINAL v14
   Mobile ONLY:
   - Rotate PDF: replace original PDF preview box with filename.
   - Compress PDF: replace blank preview box with filename.
   - Tablet/Desktop: NO CHANGE.
   ========================================================= */

@media (max-width: 767px) {

  /* =========================
     ROTATE PDF
     ========================= */

  /* Hide the "PDF Preview" heading on the original-upload card. */
  .workspace > .card:first-child .card-title {
    display: none !important;
  }

  /* Turn the upload/drop area into a compact file row once a PDF is loaded. */
  .workspace > .card:first-child #dropZone:has(#filePreview:not(.hidden)) {
    min-height: 0 !important;
    height: auto !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: default !important;
  }

  .workspace > .card:first-child #filePreview {
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
  }

  /* No original PDF rendering, page count or remove button.
     Only the filename remains, as requested. */
  .workspace > .card:first-child #pdfCanvas,
  .workspace > .card:first-child #filePages,
  .workspace > .card:first-child #removeBtn {
    display: none !important;
  }

  .workspace > .card:first-child #fileName {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 15px !important;
    line-height: 22px !important;
    font-weight: 600 !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Before a file is selected, keep the normal Choose PDF interface. */
  .workspace > .card:first-child #dropZone:not(:has(#filePreview:not(.hidden))) {
    min-height: 180px !important;
  }

  /* =========================
     COMPRESS PDF
     ========================= */

  /* When a PDF is selected, remove the large blank upload/preview box. */
  .card:has(#dropZone.has-file) #dropZone {
    display: none !important;
  }

  /* Compact file-name-only row. */
  .card:has(#dropZone.has-file) #fileBox {
    display: flex !important;
    width: 100% !important;
    min-height: 54px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 14px !important;
    box-sizing: border-box !important;

    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    box-shadow: none !important;

    align-items: center !important;
    justify-content: center !important;
  }

  /* No PDF square/icon and no file size — filename only. */
  .card:has(#dropZone.has-file) #fileBox .pdf-icon,
  .card:has(#dropZone.has-file) #fileBox .file-size {
    display: none !important;
  }

  .card:has(#dropZone.has-file) #fileBox .file-info {
    width: 100% !important;
    min-width: 0 !important;
    text-align: center !important;
  }

  .card:has(#dropZone.has-file) #fileBox .file-name {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    font-size: 15px !important;
    line-height: 22px !important;
    font-weight: 600 !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Keep the compression settings directly after the filename. */
  .card:has(#dropZone.has-file) #emptyMessage {
    display: none !important;
  }
}

/* =========================================================
   Tablet + Desktop: intentionally no overrides.
   Existing layouts remain exactly as they were.
   ========================================================= */


/* =========================================================
   8XTools FINAL v15 — Resize Image mobile workflow
   Mobile only. Tablet/Desktop untouched.
   Flow: filename → settings → Resize → Download
   ========================================================= */
@media (max-width: 767px) {
  /* Keep the action panel in the document, but remove its visual preview. */
  .workspace > .output-panel {
    display: contents !important;
  }

  .workspace > .output-panel .panel-title,
  .workspace > .output-panel #outputPreview {
    display: none !important;
  }

  .workspace > .output-panel .output-info {
    display: none !important;
  }

  .workspace > .output-panel .resize-button {
    display: block !important;
    grid-column: 1 !important;
    width: 100% !important;
    min-height: 50px !important;
    margin: 0 !important;
    order: 50 !important;
    border-radius: 12px !important;
  }

  .workspace > .output-panel .download-button {
    width: 100% !important;
    min-height: 50px !important;
    margin: 10px 0 0 !important;
    order: 51 !important;
    border-radius: 12px !important;
  }

  /* The workspace's settings panel remains first; action follows it. */
  .workspace > .panel:not(.output-panel) {
    order: 1 !important;
  }
}


/* =========================================================
   8XTools FINAL v15 — Crop Image mobile workflow
   Crop is the one image tool where a live source canvas is
   necessary so the user can select the crop area.
   Mobile only. Tablet/Desktop untouched.
   ========================================================= */
@media (max-width: 767px) {
  /* Keep the interactive crop workspace visible. */
  #cropArea {
    display: flex !important;
    min-height: 300px !important;
    max-height: 380px !important;
    padding: 10px !important;
    overflow: hidden !important;
  }

  #cropCanvas {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: 350px !important;
    height: auto !important;
    touch-action: none !important;
  }

  .workspace > .panel:has(#cropArea) {
    display: block !important;
  }

  .workspace > .panel:has(#cropArea) .panel-title {
    display: block !important;
  }

  /* Crop output preview stays hidden on mobile. */
  #outputPreview {
    display: none !important;
  }

  .output-panel .download {
    width: 100% !important;
    min-height: 48px !important;
  }
}


/* =========================================================
   8XTools FINAL v16
   MOBILE ONLY — restore action/download controls.
   Desktop + tablet: unchanged.
   ========================================================= */

@media (max-width: 767px) {

  /* ---------- RESIZE IMAGE ---------- */
  .workspace > .output-panel.output-area {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .workspace > .output-panel.output-area .panel-title,
  .workspace > .output-panel.output-area .output-preview,
  .workspace > .output-panel.output-area .output-info {
    display: none !important;
  }

  .workspace > .output-panel.output-area .resize-button {
    display: block !important;
    width: 100% !important;
    min-height: 50px !important;
    margin: 12px 0 0 !important;
  }

  .workspace > .output-panel.output-area .download-button {
    display: none;
    width: 100% !important;
    min-height: 50px !important;
    margin: 10px 0 0 !important;
    box-sizing: border-box !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ---------- CROP IMAGE ---------- */
  .workspace > .output-panel {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
  }

  .workspace > .output-panel .panel-title,
  .workspace > .output-panel .output-preview,
  .workspace > .output-panel .output-info {
    display: none !important;
  }

  .workspace > .output-panel .download {
    display: none;
    width: 100% !important;
    min-height: 50px !important;
    margin: 12px 0 0 !important;
    box-sizing: border-box !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Put the output/action area immediately after crop settings. */
  .workspace {
    display: flex !important;
    flex-direction: column !important;
  }

  .workspace > .panel:nth-child(1) {
    order: 1 !important;
  }

  .workspace > .panel:nth-child(2) {
    order: 2 !important;
  }

  .workspace > .output-panel {
    order: 3 !important;
  }
}


/* 8XTools v18 — mobile action controls */
@media (max-width: 767px) {
  .v18-mobile-action {
    box-sizing: border-box !important;
    max-width: 100% !important;
  }
}
