.module-pdf-tools .tools {
  margin: 0.75rem 0 1.8rem;
  display: flex;
  flex-direction: column;
}

.module-pdf-tools .tools-summary {
  margin: 0;
}

.module-pdf-tools .tools-summary .tools-hero h1 {
  font-size: clamp(2rem, 3.2vw, 2.8rem);
}

.module-pdf-tools .tools-summary .tools-hero .hero-text {
  max-width: 760px;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.module-pdf-tools .tools-summary .tools-stats {
  margin-top: 1rem;
}

.module-pdf-tools .tools > .tool-switcher-active-wrap {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.module-pdf-tools .tools > .tool-switcher-passive-wrap {
  margin-top: 0.5rem;
}

.module-pdf-tools .tools > .tool-workspace {
  margin-top: 0.9rem;
}

.tool-block-head h2 {
  margin: 0;
  font-size: 1.03rem;
}

.tool-block-head p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.tool-switcher-active-wrap .tool-switcher {
  margin-top: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
}

.tool-switcher .tool-card-module {
  align-items: stretch;
  min-height: 92px;
  cursor: pointer;
}

.tool-switcher-active-wrap .tool-card-module {
  min-height: 72px;
  align-items: center;
  padding: 0.58rem 0.64rem;
  transition: min-height 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tool-card-module .tool-copy {
  justify-content: center;
}

.tool-switcher-active-wrap .tool-card-module .tool-copy {
  justify-content: flex-start;
  gap: 0.12rem;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  white-space: nowrap;
  width: auto;
  max-width: fit-content;
  flex: 0 0 auto;
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #735b1f;
  background: #f3e1b2;
}

.tool-badge-live {
  color: #195739;
  border-color: #88c4a4;
  background: #d7f0e3;
}

.tool-switcher-active-wrap .tool-card-module .tool-badge {
  align-self: center;
  margin-top: 0;
}

.tool-card-module[aria-current='true'],
.tool-card-module.tool-card-module-active {
  border-color: #b7861f;
  background: #fff5da;
  box-shadow: 0 12px 26px rgba(112, 89, 35, 0.2);
  outline: 2px solid #e2c173;
  outline-offset: -1px;
}

.tool-card-module[aria-current='true'] .tool-icon,
.tool-card-module.tool-card-module-active .tool-icon {
  box-shadow: 0 10px 20px rgba(30, 41, 59, 0.24);
}

.tool-card-module[aria-current='true'] .tool-copy strong,
.tool-card-module.tool-card-module-active .tool-copy strong {
  color: #4a3814;
}

.tool-card-module[aria-current='true'] .tool-badge,
.tool-card-module.tool-card-module-active .tool-badge {
  border-color: #7bb799;
  background: #d8efdf;
  color: #1a5d3b;
  font-weight: 800;
}

.tool-card-module.is-disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.tool-switcher-active-wrap .tool-card-module .tool-copy strong {
  font-size: 0.84rem;
  line-height: 1.2;
}

.tool-switcher-active-wrap .tool-card-module .tool-copy small {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.75rem;
  line-height: 1.2;
}

.tool-switcher-active-wrap .tool-card-module:hover,
.tool-switcher-active-wrap .tool-card-module:focus-visible {
  min-height: 92px;
  align-items: flex-start;
}

.tool-switcher-active-wrap .tool-card-module:hover .tool-copy strong,
.tool-switcher-active-wrap .tool-card-module:focus-visible .tool-copy strong {
  white-space: normal;
}

.tool-switcher-active-wrap .tool-card-module:hover .tool-copy small,
.tool-switcher-active-wrap .tool-card-module:focus-visible .tool-copy small {
  -webkit-line-clamp: 3;
  font-size: 0.77rem;
  line-height: 1.25;
}

.tool-switcher-active-wrap .tool-card-module:hover .tool-badge,
.tool-switcher-active-wrap .tool-card-module:focus-visible .tool-badge {
  align-self: flex-start;
  margin-top: 0.08rem;
}

.tool-switcher-active-wrap .tool-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.tool-switcher-active-wrap .tool-icon svg {
  width: 16px;
  height: 16px;
}

.tool-switcher-active-wrap .tool-icon::before {
  width: 13px;
  height: 13px;
  top: -5px;
  left: -5px;
}

.tool-switcher-active-wrap .tool-badge {
  font-size: 0.67rem;
  padding: 0.18rem 0.47rem;
}

.tool-switcher-passive-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8efd4;
  padding: 0.15rem 0.55rem 0.55rem;
}

.tool-switcher-passive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.42rem 0.1rem 0.25rem;
}

.tool-switcher-passive-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: #604f2a;
  font-weight: 700;
}

.tool-switcher-passive-head small {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.tool-switcher-passive {
  margin-top: 0.4rem;
}

.tool-switcher-passive .tool-card-module {
  min-height: 72px;
  cursor: default;
  opacity: 0.86;
  padding: 0.58rem 0.64rem;
}

.tool-switcher-passive .tool-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.tool-switcher-passive .tool-icon svg {
  width: 16px;
  height: 16px;
}

.tool-switcher-passive .tool-icon::before {
  width: 13px;
  height: 13px;
  top: -5px;
  left: -5px;
}

.tool-switcher-passive .tool-copy strong {
  font-size: 0.84rem;
}

.tool-switcher-passive .tool-copy small {
  font-size: 0.75rem;
}

.tool-switcher-passive .tool-badge {
  font-size: 0.67rem;
  padding: 0.18rem 0.47rem;
}

.tool-workspace {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.95rem;
}

.tool-workspace.tool-workspace-pulse {
  animation: toolWorkspacePulse 0.38s ease-in-out 2;
}

@keyframes toolWorkspacePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(112, 89, 35, 0);
  }

  50% {
    transform: scale(1.01);
    box-shadow: 0 8px 22px rgba(112, 89, 35, 0.14);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(112, 89, 35, 0);
  }
}

.tool-workspace-head h2 {
  margin: 0;
  font-size: 1.2rem;
  text-align: center;
}

.tool-workspace-head p {
  margin: 0.35rem auto 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 760px;
  text-align: center;
}

.pdf-tool-host {
  margin-top: 0.8rem;
}

.merge-form,
.tool-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tool-grid-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.tool-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: #4f4125;
  font-weight: 600;
  font-size: 0.9rem;
}

.tool-field input[type='file'],
.tool-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #3e331c;
  min-height: 40px;
  padding: 0.55rem 0.65rem;
  font: inherit;
}

.tool-field input[type='file'] {
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.25;
  padding: 0.35rem 0.4rem;
}

.tool-field input[type='file']::file-selector-button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #2f2a1e;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.55rem 0.95rem;
  margin-right: 0.6rem;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.tool-field input[type='file']::file-selector-button:hover {
  filter: brightness(0.95);
}

.tool-field input[type='file']::-webkit-file-upload-button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #2f2a1e;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.55rem 0.95rem;
  margin-right: 0.6rem;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.tool-field input[type='file']::-webkit-file-upload-button:hover {
  filter: brightness(0.95);
}

.tool-field input[type='file']:focus-visible {
  outline: 2px solid #dcc27d;
  outline-offset: 2px;
}

.tool-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.tool-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.merge-upload-box {
  margin-top: 0;
}

.merge-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.merge-upload-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.merge-selected {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7edd0;
  padding: 0.75rem;
}

.merge-selected h3 {
  margin: 0;
  font-size: 0.95rem;
}

.merge-file-list {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.image-to-pdf-file-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  align-items: center;
  color: #4f4125;
}

.image-to-pdf-file-order {
  font-weight: 700;
}

.image-to-pdf-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.image-to-pdf-file-size {
  color: #6f6348;
  font-size: 0.8rem;
}

.image-to-pdf-file-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.merge-file-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  align-items: center;
  color: #4f4125;
}

.merge-file-order {
  font-weight: 700;
}

.merge-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.merge-file-size {
  color: #6f6348;
  font-size: 0.8rem;
}

.merge-file-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.merge-order-btn {
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: #5b4a24;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.merge-order-btn:hover {
  background: #f4e4b5;
  border-color: #c79b31;
}

.merge-order-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.merge-empty {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.merge-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.merge-submit-btn[disabled] {
  cursor: not-allowed;
  filter: grayscale(0.12);
  opacity: 0.72;
}

.merge-status {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.merge-status[data-state='loading'] {
  color: #6d5318;
}

.merge-status[data-state='success'] {
  color: #245e3f;
  font-weight: 700;
}

.merge-status[data-state='error'] {
  color: #9e2b1c;
  font-weight: 700;
}

@media (max-width: 980px) {
  .tool-grid-fields {
    grid-template-columns: 1fr;
  }

  .tool-switcher-active-wrap .tool-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-workspace.tool-workspace-pulse {
    animation: none;
  }
}

@media (max-width: 760px) {
  .module-pdf-tools .tools {
    margin-top: 0.6rem;
  }

  .tool-workspace {
    padding: 0.75rem;
  }

  .merge-selected {
    padding: 0.65rem;
  }

  .tool-switcher-active-wrap .tool-switcher {
    grid-template-columns: 1fr;
  }

  .merge-file-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'order name controls'
      '. size controls';
  }

  .image-to-pdf-file-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'order name controls'
      '. size controls';
  }

  .image-to-pdf-file-order {
    grid-area: order;
  }

  .image-to-pdf-file-name {
    grid-area: name;
  }

  .image-to-pdf-file-size {
    grid-area: size;
    justify-self: start;
    margin-left: 0.2rem;
  }

  .image-to-pdf-file-controls {
    grid-area: controls;
    align-self: center;
  }

  .merge-file-order {
    grid-area: order;
  }

  .merge-file-name {
    grid-area: name;
  }

  .merge-file-size {
    grid-area: size;
    justify-self: start;
    margin-left: 0.2rem;
  }

  .merge-file-controls {
    grid-area: controls;
    align-self: center;
  }

  .tool-switcher-passive-wrap {
    padding: 0.12rem 0.45rem 0.45rem;
  }

  .tool-switcher-passive-head {
    padding: 0.36rem 0.05rem 0.3rem;
  }

  .tool-block-head h2 {
    font-size: 0.98rem;
  }

  .tool-block-head p {
    font-size: 0.8rem;
  }
}
