/* Image icons for the /pdf-tools hub cards */
.tool-icon.tool-icon--img {
  width: 64px;
  height: 64px;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
}
.tool-icon.tool-icon--img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* "Other PDF tools" cards at the bottom of each tool page */
.other-tool-icon.other-tool-icon--img {
  width: 56px;
  height: 56px;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
}
.other-tool-icon.other-tool-icon--img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* PDF page headings stay on one line on desktop; wrap evenly on small screens */
.tool-header h1 { text-wrap: balance; }

/* ============================================================
   PDF TOOL PAGES — two-step layout
   Step 1: big "Select file" button. Step 2: file cards + side panel.
   ============================================================ */
.tool-header .tool-sub {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 56ch;
  margin: 0 auto;
}

/* Step 1 */
.pdf-dropzone {
  padding: 64px 32px 52px;
}
.pdf-select-btn {
  font-size: 20px;
  font-weight: 700;
  padding: 20px 56px;
  min-width: 320px;
  border-radius: 16px;
}
.pdf-dropzone .pdf-drop-hint {
  margin-top: 18px;
  font-size: 14px;
}
.pdf-dropzone .pdf-limits {
  margin-top: 6px;
  font-size: 12.5px;
  opacity: 0.8;
}

/* Step 2 */
.pdf-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}
.pdf-files-area {
  border: 2px dashed transparent;
  border-radius: 20px;
  padding: 18px;
  min-height: 340px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.pdf-files-area.is-dragover {
  border-color: var(--primary);
  background: rgba(109, 94, 247, 0.06);
}
.pdf-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pdf-file-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px 14px;
  text-align: center;
}
.pdf-file-thumb {
  height: 120px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
}
.pdf-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pdf-file-badge {
  background: var(--gradient);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-radius: 10px;
}
.pdf-file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-file-size {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.pdf-file-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.85);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.pdf-file-remove:hover { background: var(--error); border-color: var(--error); }
.pdf-add-tile {
  min-height: 190px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.pdf-add-tile:hover { border-color: var(--primary); color: var(--text); }
.pdf-add-plus {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 26px;
  line-height: 44px;
}

/* Side panel */
.pdf-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
}
.pdf-sidebar h3 {
  font-size: 20px;
  font-weight: 800;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.pdf-sidebar .pdf-convert-btn {
  margin-top: auto;
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  padding: 16px 20px;
  border-radius: 14px;
}
.pdf-sidebar-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 760px) {
  .pdf-workspace { grid-template-columns: 1fr; }
  .pdf-select-btn { min-width: 0; width: 100%; padding: 18px 24px; }
  .pdf-files-area { min-height: 0; }
}

/* "Add more files" sits directly above Convert */
.pdf-sidebar .pdf-add-btn {
  margin-top: auto;
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 14px;
}
.pdf-sidebar .pdf-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pdf-sidebar .pdf-add-btn + .pdf-convert-btn { margin-top: 0; }

/* ===== Split PDF range builder ===== */
.pdf-split-mode .pdf-file-grid { display: none; }
.pdf-split-mode .pdf-files-area { display: block; padding: 20px; }
.split-preview { width: 100%; }
.split-head { font-weight: 700; margin-bottom: 14px; }
.split-hint, .split-loading, .split-msg { font-size: 13px; color: var(--text-secondary); }
.split-msg { color: #ff8a8a; min-height: 0; }
.split-msg:empty { display: none; }
.split-ranges { display: flex; flex-wrap: wrap; gap: 16px; }
.split-range-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; min-width: 150px; }
.split-range-title { font-weight: 700; font-size: 14px; text-align: center; margin-bottom: 10px; }
.split-range-thumbs { display: flex; align-items: center; justify-content: center; gap: 8px; }
.split-range-cap { text-align: center; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.split-dots { font-size: 22px; color: var(--text-secondary); }
.split-thumb { position: relative; width: 96px; background: #fff; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.split-thumb canvas { display: block; width: 100%; height: auto; min-height: 120px; background: #fff; }
.split-thumb-num { position: absolute; right: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 8px; }
.split-pages { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.split-more { align-self: center; color: var(--text-secondary); font-size: 14px; }
.split-tabs, .split-modes { display: flex; gap: 6px; background: rgba(255,255,255,.05); border-radius: 12px; padding: 4px; }
.split-tab, .split-mode { flex: 1; border: 0; background: transparent; color: var(--text-secondary); font-weight: 700; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.split-tab.is-active, .split-mode.is-active { background: var(--gradient); color: #fff; }
.split-body { display: flex; flex-direction: column; gap: 12px; }
.split-range-edit { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.split-range-edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; }
.split-del { border: 0; background: transparent; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.split-fromto, .split-fixed { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.split-fixed { grid-template-columns: auto 1fr auto; }
.split-num { width: 100%; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,.05); color: inherit; font-size: 14px; }
.split-add { width: 100%; }
@media (max-width: 760px) { .split-thumb { width: 80px; } }

/* ===== Compress level cards + PDF thumbnails ===== */
.level-group { display: flex; flex-direction: column; gap: 12px; }
.level-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; background: rgba(255,255,255,.03); transition: border-color .15s, background .15s; }
.level-card:hover { border-color: rgba(255,255,255,.25); }
.level-card.is-selected { border-color: #8b5cf6; background: rgba(139,92,246,.12); }
.level-radio { position: absolute; opacity: 0; pointer-events: none; }
.level-dot { flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-secondary); position: relative; }
.level-card.is-selected .level-dot { border-color: #8b5cf6; }
.level-card.is-selected .level-dot::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #8b5cf6; }
.level-radio:focus-visible + .level-dot { outline: 2px solid #8b5cf6; outline-offset: 2px; }
.level-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-secondary); }
.level-text strong { font-size: 15px; color: inherit; }
.level-card.is-selected .level-text strong { color: #fff; }
.pdf-file-canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.35); }

/* ===== Rotate PDF controls ===== */
.rot-ui { display: flex; flex-direction: column; gap: 12px; }
.rot-info { font-size: 13px; color: var(--text-secondary); background: rgba(139,92,246,.1); border: 1px solid rgba(139,92,246,.35); border-radius: 12px; padding: 12px 14px; }
.rot-head { display: flex; justify-content: space-between; align-items: center; }
.rot-reset { border: 0; background: transparent; color: #a78bfa; text-decoration: underline; cursor: pointer; font-weight: 600; }
.rot-btn { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); background: rgba(255,255,255,.04); color: inherit; border-radius: 12px; overflow: hidden; cursor: pointer; padding: 0; font-weight: 700; letter-spacing: .04em; }
.rot-btn:hover { border-color: #8b5cf6; }
.rot-btn-icon { width: 52px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--gradient); color: #fff; font-size: 22px; }
.rot-btn-label { padding: 0 18px; text-transform: uppercase; font-size: 14px; }
.rot-status { font-size: 13px; color: var(--text-secondary); text-align: center; }
.rot-msg { font-size: 13px; color: #ff8a8a; }
.rot-msg:empty { display: none; }
.pdf-files-area .pdf-file-thumb canvas, .rot-page canvas { transition: transform .25s ease; }
.pdf-file-card { position: relative; }
.rot-card-btn { z-index: 3; position: absolute; top: 8px; right: 44px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #111; font-size: 17px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.pdf-file-card:hover .rot-card-btn, .rot-card-btn:focus-visible { opacity: 1; }
.rot-label { display: block; margin-top: 4px; }
.rot-filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rot-filter { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.04); color: var(--text-secondary); font-weight: 600; font-size: 13px; cursor: pointer; }
.rot-filter-icon { font-size: 22px; line-height: 1; }
.rot-filter.is-active { border-color: #8b5cf6; background: rgba(139,92,246,.14); color: #fff; }
.rot-pages { margin-top: 22px; }
.rot-pages-head { font-weight: 700; margin-bottom: 12px; }
.rot-pages-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.rot-page { position: relative; width: 110px; height: 150px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.04); border-radius: 10px; overflow: hidden; }
.rot-page canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.rot-page-num { position: absolute; right: 5px; bottom: 5px; font-size: 11px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 8px; }
.rot-page-more { align-self: center; color: var(--text-secondary); font-size: 14px; }

.pdf-file-thumb { position: relative; z-index: 0; }
.pdf-file-remove { z-index: 3; }

/* Per-file rotate button: same look as the remove button, always visible, on top of the preview */
.pdf-file-card .rot-card-btn {
  top: 6px; right: 38px; width: 26px; height: 26px; z-index: 5;
  border-radius: 50%; border: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.85); color: var(--text);
  font-size: 15px; line-height: 1; padding: 0;
  opacity: 1;
}
.pdf-file-card .rot-card-btn:hover { background: var(--primary); border-color: var(--primary); }
.pdf-file-card .pdf-file-remove { z-index: 5; }

.rot-page-btn { position: absolute; top: 5px; right: 5px; z-index: 5; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: rgba(15,17,23,.85); color: var(--text); font-size: 15px; line-height: 1; padding: 0; cursor: pointer; }
.rot-page-btn:hover { background: var(--primary); border-color: var(--primary); }

.pdf-files-area.rot-single .pdf-file-grid { display: none; }
.rot-single .rot-pages { margin-top: 0; }
.rot-pages-headrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.rot-pages-headrow .rot-pages-head { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rot-remove-file { border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.rot-remove-file:hover { background: var(--error); border-color: var(--error); }

.rot-dim { opacity: 0.28; filter: grayscale(0.6); transition: opacity .2s; }

.pdf-order { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 8px; }
.pdf-order-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,.06); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
.pdf-order-btn:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); }
.pdf-order-btn:disabled { opacity: .3; cursor: default; }
.pdf-order-num { font-size: 13px; font-weight: 700; min-width: 16px; text-align: center; color: var(--text-secondary); }
.pdf-sidebar .pdf-sort-btn { width: 100%; padding: 12px 18px; border-radius: 14px; font-weight: 600; }

/* Remove pages */
.rm-page { cursor: pointer; border: 2px solid transparent; padding: 0; font: inherit; }
.rm-page:hover { border-color: rgba(139,92,246,.6); }
.rm-x { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-size: 42px; font-weight: 800; color: #fff; background: rgba(220,38,38,.55); }
.rm-page.is-removed { border-color: #dc2626; }
.rm-page.is-removed .rm-x { display: flex; }
.rm-page.is-removed canvas { opacity: .5; }
.rm-status { font-size: 13px; color: var(--text-secondary); text-align: center; }

/* ===== Result panel (centred) ===== */
body[data-pdf-endpoint] .result-panel:not(.is-hidden) {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 24px 52px; gap: 14px;
}
.result-check {
  width: 76px; height: 76px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 700; line-height: 1;
  color: #34d399; background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.45);
  box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.06);
}
body[data-pdf-endpoint] .result-panel h3 { font-size: 28px; font-weight: 800; margin: 6px 0 0; }
body[data-pdf-endpoint] #result-filename {
  margin: 0 auto; align-self: center;
  max-width: min(100%, 460px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 8px 18px; border-radius: 999px; font-size: 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
}
body[data-pdf-endpoint] .result-actions {
  display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 14px; width: 100%;
}
body[data-pdf-endpoint] #download-btn {
  min-width: 280px; max-width: 100%; padding: 17px 44px; font-size: 18px; font-weight: 700; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}
body[data-pdf-endpoint] #start-over-btn {
  border: 0; background: transparent; color: var(--text-secondary); font-weight: 600; padding: 8px 14px;
  text-decoration: underline; text-underline-offset: 4px;
}
body[data-pdf-endpoint] #start-over-btn:hover { color: var(--text); }
