.tool-card__desc--help {
  margin-top: 14px;
}

.btn:disabled {
  opacity: 0.65;
}

.tool-error {
  line-height: 1.6;
}

.tool-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, var(--success) 8%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, var(--success) 30%, var(--md-sys-color-outline-variant));
  color: var(--success);
  font-size: 0.875rem;
  line-height: 1.6;
}

.tool-status.is-loading::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--success) 25%, transparent);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.result-header__desc {
  margin: 6px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.background-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.background-switch__label {
  margin-right: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.background-switch__btn {
  appearance: none;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface-variant);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.background-switch__btn:hover,
.background-switch__btn.is-active {
  background: var(--md-sys-color-primary-container);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 40%, transparent);
  color: var(--md-sys-color-on-primary-container);
}

.tool-help h2 {
  margin: 22px 0 10px;
}

.tool-help h2:first-child {
  margin-top: 0;
}

.tool-help p {
  line-height: 1.75;
}

.tool-help ul {
  margin: 0;
  padding-left: 1.25em;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.75;
}

.tool-help li + li {
  margin-top: 4px;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-input-wrap {
  position: relative;
}

.file-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 180px;
  padding: 20px;
  text-align: center;
  border: 2px dashed var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.file-dropzone:hover,
.file-dropzone.is-active {
  border-color: var(--md-sys-color-primary);
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 45%, var(--md-sys-color-surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent);
}

.file-dropzone__icon {
  font-size: 40px;
  line-height: 1;
  color: var(--md-sys-color-primary);
}

.file-dropzone__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.file-dropzone__desc {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

.selected-file {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  word-break: break-all;
}

.preview-wrap {
  margin-top: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface);
  overflow: hidden;
}

.preview-stage--checker {
  background-color: var(--md-sys-color-surface);
  background-image:
    linear-gradient(45deg, rgba(148, 163, 184, 0.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.16) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.preview-stage--white {
  background-color: #ffffff;
  background-image: none;
}

.preview-stage--black {
  background-color: #111827;
  background-image: none;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media (max-width: 600px) {
  .result-actions {
    width: 100%;
  }

  .result-actions .btn {
    flex: 1 1 140px;
  }

  .background-switch {
    align-items: flex-start;
  }

  .background-switch__label {
    width: 100%;
    margin-right: 0;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    min-height: 220px;
  }}
