.trn {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.trn__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.trn__intro {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.trn__eyebrow {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent-strong);
}

.trn__note {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.trn-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.trn-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.trn-switch__track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  transition: background var(--duration-fast) var(--ease-default), border-color var(--duration-fast) var(--ease-default);
}

.trn-switch__dot {
  position: absolute;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-text-muted);
  transition: transform var(--duration-fast) var(--ease-default), background var(--duration-fast) var(--ease-default);
}

.trn-switch input:checked + .trn-switch__track {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent);
}

.trn-switch input:checked + .trn-switch__track .trn-switch__dot {
  transform: translateX(16px);
  background: var(--color-accent-strong);
}

.trn-switch input:focus-visible + .trn-switch__track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.trn-switch__label {
  font-weight: var(--weight-medium);
}

.trn-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: var(--space-3);
}

.trn-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-default), box-shadow var(--duration-fast) var(--ease-default);
}

.trn-panel:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.trn-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
}

.trn-panel__label {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.trn-combo {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 300px;
}

.trn-combo__input {
  width: 100%;
  min-width: 0;
  padding: 6px 30px 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  cursor: text;
}

.trn-combo__input:hover {
  border-color: var(--color-border);
}

.trn-combo.is-open .trn-combo__input,
.trn-combo__input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.trn-combo__toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.trn-combo__toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.trn-combo__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: max(100%, 268px);
  max-width: min(360px, 88vw);
  max-height: 296px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}

.trn-combo__sep {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: 0.7rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.trn-combo__none {
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.trn-opt {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.trn-opt.is-active,
.trn-opt:hover {
  background: var(--color-accent-subtle);
}

.trn-opt[aria-selected="true"] {
  font-weight: var(--weight-semibold);
}

.trn-opt__native {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.trn-opt__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.trn-opt__code {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--color-text-muted);
  opacity: 0.8;
}

.trn-opt--auto .trn-opt__native {
  color: var(--color-accent-strong);
}

.trn-editor {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 240px;
}

.trn-textarea,
.trn-output {
  width: 100%;
  min-height: 240px;
  padding: var(--space-4);
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-base);
  line-height: 1.65;
}

.trn-textarea {
  resize: vertical;
  outline: none;
}

.trn-textarea::placeholder {
  color: var(--color-text-muted);
}

.trn-output {
  overflow-y: auto;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.trn-output:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -4px;
}

.trn-output__empty {
  margin: 0;
  color: var(--color-text-muted);
}

.trn-output.is-filled {
  color: var(--color-text);
}

.trn-detect {
  position: absolute;
  left: var(--space-4);
  bottom: var(--space-3);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - var(--space-8));
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--color-accent-subtle);
  color: var(--color-accent-strong);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-sm);
}

.trn-detect__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.trn-detect.is-loading .trn-detect__dot {
  animation: trn-pulse 1s ease-in-out infinite;
}

.trn-detect__meta,
.trn-detect__method {
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
}

.trn-detect__method {
  font-size: 0.68rem;
}

@keyframes trn-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8) }
  50% { opacity: 1; transform: scale(1.15) }
}

.trn-panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 46px;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
}

.trn-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.trn-count.is-warn {
  color: #b45309;
}

.trn-count.is-over {
  color: #c03737;
  font-weight: var(--weight-semibold);
}

[data-theme="dark"] .trn-count.is-warn { color: #fbbf24 }
[data-theme="dark"] .trn-count.is-over { color: #f87171 }

.trn-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.trn-action {
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default), background var(--duration-fast) var(--ease-default);
}

.trn-action:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.trn-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.trn-action.is-error {
  color: #c03737;
}

.trn-swap-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.trn-swap {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-default), border-color var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default);
}

.trn-swap:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-strong);
  transform: rotate(180deg);
}

.trn-swap:disabled {
  opacity: 0.5;
  cursor: default;
}

.trn__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.trn-submit {
  position: relative;
  width: 100%;
  min-height: 52px;
  justify-content: center;
}

.btn.is-loading .trn-submit__label {
  opacity: 0.85;
}

.trn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: trn-spin 0.7s linear infinite;
}

.btn.is-loading .trn-spinner,
.trn-loading .trn-spinner {
  display: inline-block;
}

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

.trn-shortcuts {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

.trn-provider {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.trn-provider__label {
  color: var(--color-text-muted);
}

.trn-provider__link {
  color: var(--color-accent-strong);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.trn-provider__link:hover {
  text-decoration: underline;
}

.trn-badge {
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-brand-subtle);
  color: var(--color-text-secondary);
  font-size: 0.68rem;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.trn-badge--fallback {
  background: rgba(180, 83, 9, 0.14);
  color: #9a4a06;
}

[data-theme="dark"] .trn-badge--fallback {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

.trn-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #e7b4b4;
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: rgba(214, 69, 69, 0.08);
  color: #8f2c2c;
  font-size: var(--text-sm);
}

.trn-alert.is-warn {
  border-color: #e7cf9e;
  background: rgba(180, 83, 9, 0.08);
  color: #8a4b09;
}

[data-theme="dark"] .trn-alert {
  border-color: #6e3434;
  background: rgba(214, 69, 69, 0.14);
  color: #f3b4b4;
}

[data-theme="dark"] .trn-alert.is-warn {
  border-color: #6d5526;
  background: rgba(251, 191, 36, 0.12);
  color: #f3d28a;
}

.trn-alert__text {
  flex: 1 1 220px;
}

.trn-alert__retry {
  flex: 0 0 auto;
}

.trn-status {
  min-height: 1.2em;
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

.trn__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
}

.trn-privacy,
.trn-providers {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.trn-privacy {
  max-width: 66ch;
}

.trn-providers a {
  color: var(--color-accent-strong);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.trn-providers a:hover {
  text-decoration: underline;
}

.trn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 320px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.trn-loading .trn-spinner {
  color: var(--color-accent-strong);
}

@media (max-width: 760px) {
  .trn-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .trn-panel {
    min-height: 280px;
  }

  .trn-panel__head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .trn-combo {
    max-width: none;
    width: 100%;
  }

  .trn-swap-wrap {
    padding: var(--space-1) 0;
  }

  .trn-swap {
    transform: rotate(90deg);
  }

  .trn-swap:hover {
    transform: rotate(270deg);
  }

  .trn-editor,
  .trn-textarea,
  .trn-output {
    min-height: 200px;
  }

  .trn__footer {
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .trn-panel__head {
    gap: var(--space-2);
  }

  .trn-panel__foot {
    flex-wrap: wrap;
  }

  .trn-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
