.pdf-image-tool {
  display: grid;
  gap: 22px;
}

.pdf-image-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 550;
  letter-spacing: -0.035em;
}

.pdf-image-heading p {
  max-width: 1180px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.pdf-image-workspace {
  min-height: 620px;
  padding: 0;
  overflow: hidden;
}

.pdf-image-toolbar {
  display: grid;
  padding: 18px;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.pdf-image-toolbar-top {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pdf-image-file-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.pdf-image-file-summary > div {
  min-width: 0;
}

.pdf-image-file-summary > svg {
  flex: 0 0 24px;
  color: var(--brand);
}

.pdf-image-file-summary strong,
.pdf-image-file-summary span {
  display: block;
}

.pdf-image-file-summary strong {
  max-width: min(720px, 62vw);
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.pdf-image-file-summary span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.pdf-image-controls {
  display: grid;
  width: 100%;
  min-width: 0;
  align-items: center;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.pdf-image-select-field {
  display: grid;
  position: relative;
  width: auto;
  height: 64px;
  min-width: 0;
  padding: 9px 42px 7px 16px;
  align-content: center;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.pdf-image-select-field:focus-within {
  border-color: rgba(207, 75, 69, 0.48);
  box-shadow: 0 0 0 3px rgba(207, 75, 69, 0.08);
}

.pdf-image-select-field > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.pdf-image-select-field > select {
  width: 100%;
  min-width: 0;
  height: 26px;
  padding: 0;
  color: var(--ink);
  background-color: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  line-height: 26px;
  appearance: none;
}

.pdf-image-select-field::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transform: translateY(-50%);
  background: center / 18px 18px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237b8492' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.pdf-image-select-field:has(select:disabled) {
  background: #f2efed;
}

.pdf-image-select-field:has(select:disabled) > span,
.pdf-image-select-field > select:disabled {
  color: var(--soft-text);
}

.pdf-image-primary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.pdf-image-primary-actions .g_button {
  min-width: 118px;
  white-space: nowrap;
}

.pdf-image-icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
}

.pdf-image-icon-button:hover:not(:disabled) {
  color: var(--brand);
  border-color: rgba(207, 75, 69, 0.22);
}

.pdf-image-icon-button:disabled {
  color: var(--soft-text);
  cursor: not-allowed;
}

.pdf-image-password {
  display: grid;
  margin: 16px 18px 0;
  padding: 16px;
  align-items: end;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 320px) auto;
  gap: 12px;
  background: var(--brand-pale);
  border: 1px solid rgba(207, 75, 69, 0.2);
  border-radius: 14px;
}

.pdf-image-password strong,
.pdf-image-password span {
  display: block;
}

.pdf-image-password span {
  margin-top: 4px;
  color: var(--muted);
}

.pdf-image-progress {
  margin: 0;
  padding: 14px 16px;
  background: #faf8f7;
  border-radius: 14px;
}

.pdf-image-progress > div {
  display: flex;
  margin-bottom: 9px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pdf-image-progress strong {
  font-weight: 550;
}

.pdf-image-progress span {
  color: var(--muted);
}

.pdf-image-progress progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 999px;
}

.pdf-image-progress progress::-webkit-progress-bar {
  background: #ebe6e3;
  border-radius: 999px;
}

.pdf-image-progress progress::-webkit-progress-value {
  background: var(--brand);
  border-radius: 999px;
}

.pdf-image-progress progress::-moz-progress-bar {
  background: var(--brand);
  border-radius: 999px;
}

.pdf-image-message {
  margin: 16px 18px 0;
  padding: 12px 14px;
  color: var(--muted);
  background: #faf8f7;
  border-radius: 12px;
}

.pdf-image-message[data-tone="error"] {
  color: var(--brand);
  background: var(--brand-pale);
}

.pdf-image-empty {
  display: grid;
  min-height: 500px;
  padding: 42px 20px;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.pdf-image-empty > svg {
  color: var(--brand);
}

.pdf-image-empty h2 {
  margin: 18px 0 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 550;
}

.pdf-image-empty p {
  max-width: 680px;
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.pdf-image-empty.is-dragging {
  background: var(--brand-pale);
  outline: 2px dashed rgba(207, 75, 69, 0.45);
  outline-offset: -14px;
}

.pdf-image-results {
  padding: 18px;
}

.pdf-image-results > header {
  display: flex;
  margin-bottom: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pdf-image-results > header > div:first-child {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.pdf-image-result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.pdf-image-results h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 550;
}

.pdf-image-results header span {
  color: var(--muted);
}

.pdf-image-gallery {
  display: grid;
  position: relative;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  user-select: none;
}

.pdf-image-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.pdf-image-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(207, 75, 69, 0.14);
}

.pdf-image-card-preview {
  display: grid;
  min-height: 230px;
  padding: 10px;
  place-items: center;
  background: #faf8f7;
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}

.pdf-image-card img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.pdf-image-card footer {
  display: flex;
  min-height: 56px;
  padding: 8px 10px 8px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pdf-image-card footer div {
  min-width: 0;
}

.pdf-image-card footer strong,
.pdf-image-card footer span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-image-card-select,
.pdf-image-card-delete {
  display: inline-flex;
  position: absolute;
  top: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.pdf-image-card-select {
  left: 10px;
}

.pdf-image-card-delete {
  right: 10px;
}

.pdf-image-card.is-selected .pdf-image-card-select {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.pdf-image-card-delete:hover,
.pdf-image-card-delete:focus-visible {
  color: var(--brand);
  border-color: rgba(207, 75, 69, 0.3);
}

.pdf-image-selection-box {
  position: absolute;
  z-index: 10;
  display: none;
  pointer-events: none;
  background: rgba(207, 75, 69, 0.1);
  border: 2px dashed var(--brand);
  border-radius: 8px;
}

.pdf-image-gallery.is-selecting {
  cursor: crosshair;
}

.pdf-image-card footer strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
}

.pdf-image-card footer span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pdf-image-confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(51, 57, 66, 0.16);
}

.pdf-image-confirm-dialog::backdrop {
  background: rgba(51, 57, 66, 0.34);
}

.pdf-image-confirm-dialog h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 550;
}

.pdf-image-confirm-dialog p {
  margin: 12px 0 20px;
  color: var(--muted);
  line-height: 1.75;
}

.pdf-image-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 1100px) {
  .pdf-image-controls { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 760px) {
  .pdf-image-file-summary strong { max-width: calc(100vw - 150px); }
  .pdf-image-controls { grid-template-columns: 1fr; }
  .pdf-image-primary-actions { justify-content: stretch; }
  .pdf-image-primary-actions .g_button { flex: 1 1 140px; }
  .pdf-image-password { grid-template-columns: 1fr; }
  .pdf-image-results > header { align-items: stretch; flex-direction: column; }
  .pdf-image-result-actions { justify-content: stretch; }
  .pdf-image-result-actions .g_button { flex: 1 1 130px; }
}

@media (max-width: 480px) {
  .pdf-image-gallery { grid-template-columns: 1fr; }
  .pdf-image-empty { min-height: 420px; }
}
