:root {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #162420;
  background: #f3f6f5;
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: clamp(1.25rem, 4vw, 3rem) 1rem 3rem;
}

.exchange-shell {
  max-width: 44rem;
  margin-inline: auto;
  display: grid;
  gap: 1.1rem;
}

.exchange-header {
  display: grid;
  gap: 0.35rem;
}

.exchange-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #186346;
}

h1 {
  font-size: clamp(1.45rem, 3.2vw, 1.85rem);
  line-height: 1.25;
  margin: 0;
  color: #10201b;
}

.exchange-subtitle {
  margin: 0;
  color: #4a5d56;
  font-size: 0.95rem;
}

.exchange-card {
  background: #ffffff;
  border: 1px solid #d7e1dc;
  border-radius: 12px;
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: 0 4px 18px rgba(16, 32, 27, 0.04);
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.exchange-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: #eef5f2;
  color: #26483b;
  font-size: 0.875rem;
}

.exchange-rules span::before {
  content: "• ";
  color: #186346;
  font-weight: 700;
}

form, .success-box {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

label {
  font-weight: 650;
  color: #162420;
}

.field-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
}

.input-counter {
  color: #52665e;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: #186346;
  cursor: pointer;
  text-decoration: underline;
}

textarea {
  width: 100%;
  min-width: 0;
  font: 0.95rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.7rem 0.8rem;
  border: 1px solid #b6c6be;
  border-radius: 8px;
  color: #12211c;
  background: #fbfdfc;
  resize: vertical;
}

textarea:focus-visible, button:focus-visible {
  outline: 2px solid #186346;
  outline-offset: 2px;
}

#new-code {
  background: #f4faf7;
  border-color: #9dc5b4;
}

.submit-row, .action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.primary-btn, .secondary-btn, .mini-copy-btn {
  font: inherit;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.65rem;
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  border: 1px solid #175c41;
  background: #175c41;
  color: #ffffff;
}

.primary-btn:hover:not(:disabled) {
  background: #124a34;
}

.submit-row .primary-btn {
  width: 100%;
}

.secondary-btn {
  border: 1px solid #175c41;
  background: #ffffff;
  color: #175c41;
}

.secondary-btn:hover:not(:disabled) {
  background: #eef6f2;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status-banner {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: #eaf5ef;
  color: #16543b;
  font-weight: 500;
  font-size: 0.94rem;
}

.status-banner[data-error="true"] {
  background: #fdf0ee;
  color: #992d1f;
}

.badge-ok {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #dff2e8;
  color: #14573c;
}

.details-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-top: 1px solid #e4ece8;
  padding-top: 0.85rem;
}

#result-heading {
  font-size: 1rem;
  margin: 0;
}

.details-meta {
  font-size: 0.85rem;
  color: #52665e;
}

.details-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.detail-item {
  border: 1px solid #e2ebe6;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  display: grid;
  gap: 0.35rem;
  background: #fcfefd;
  min-width: 0;
}

.detail-item.is-failed {
  border-color: #f0d1cc;
  background: #fffafa;
}

.detail-item.is-retry {
  border-color: #ebd8ad;
  background: #fffdf7;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.line-tag {
  font-weight: 650;
  color: #2f433c;
}

.product-tag {
  font-size: 0.76rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: #e8eff4;
  color: #22445e;
  font-weight: 600;
}

.state-tag {
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
}

.state-tag.success { background: #dff2e8; color: #14573c; }
.state-tag.failed { background: #fae4e1; color: #962b1d; }
.state-tag.duplicate { background: #eceff1; color: #4f5f66; }
.state-tag.retry { background: #faefd4; color: #805600; }

.detail-codes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.old-card-text {
  color: #64766f;
  text-decoration: line-through;
}

.arrow-text {
  color: #175c41;
  font-weight: 700;
}

.new-card-text {
  color: #10241c;
  font-weight: 650;
}

.mini-copy-btn {
  min-height: 1.9rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  border: 1px solid #bdd3c8;
  background: #ffffff;
  color: #175c41;
  border-radius: 6px;
}

.detail-reason {
  font-size: 0.85rem;
  color: #8c3123;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .action-bar button {
    flex: 1 1 100%;
  }
}
