:root {
  --compare-a: #e7344f;
  --compare-b: #176bff;
  --compare-ink: #111;
  --compare-paper: #fff;
  --compare-muted: #686868;
}

body.compare-page {
  min-height: 100vh;
  background: #ededed;
  color: var(--compare-ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, textarea { font: inherit; letter-spacing: 0; }
.compare-shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 80px; }
.compare-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 4px solid #111; }
.compare-kicker { margin-bottom: 4px; color: var(--compare-muted); font-size: 12px; font-weight: 900; }
.compare-heading h1 { font-size: clamp(30px, 5vw, 58px); line-height: 1; font-weight: 950; }
.compare-back, .compare-submit, .compare-share { border: 2px solid #111; background: #fff; color: #111; box-shadow: 3px 3px 0 #111; padding: 9px 13px; font-size: 13px; font-weight: 900; text-decoration: none; cursor: pointer; }
.compare-back:hover, .compare-share:hover { background: var(--accent); }

.compare-inputs { display: grid; grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr) auto; align-items: stretch; gap: 14px; padding: 24px 0; border-bottom: 2px solid #111; }
.compare-source { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 4px 10px; min-width: 0; }
.source-mark { grid-row: 1 / span 3; display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--compare-a); font-size: 18px; font-weight: 950; }
.source-b .source-mark { background: var(--compare-b); }
.source-label { align-self: center; font-size: 13px; font-weight: 900; }
.compare-local-select { grid-column: 2; min-width: 0; width: 100%; height: 34px; border: 2px solid #111; border-radius: 0; background: #fff; padding: 4px 8px; color: #111; font-size: 12px; font-weight: 800; }
.compare-source textarea { grid-column: 1 / -1; width: 100%; min-height: 74px; resize: vertical; border: 2px solid #111; border-radius: 0; background: #fff; padding: 11px 12px; color: #111; font-size: 13px; line-height: 1.45; outline: none; }
.source-a textarea:focus { box-shadow: 4px 4px 0 var(--compare-a); }
.source-b textarea:focus { box-shadow: 4px 4px 0 var(--compare-b); }
.source-status { min-height: 17px; grid-column: 1 / -1; color: var(--compare-muted); font-size: 11px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-swap { align-self: center; width: 42px; height: 42px; border: 2px solid #111; background: #111; color: #fff; font-size: 22px; cursor: pointer; }
.compare-swap:hover { background: var(--accent); color: #111; }
.compare-submit { align-self: center; min-height: 44px; background: var(--accent); white-space: nowrap; }
.compare-submit:disabled { opacity: .55; cursor: wait; }
.compare-error { margin: 20px 0; border-left: 6px solid var(--danger); background: #fff; padding: 14px 16px; font-size: 13px; font-weight: 800; }

.compare-results { padding-top: 28px; }
.compare-deck-heads { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 18px; }
.compare-deck-heads > div { display: flex; min-width: 0; align-items: center; gap: 12px; }
.compare-deck-heads > div > span { display: grid; flex: 0 0 42px; place-items: center; width: 42px; height: 42px; background: var(--compare-a); color: #fff; font-size: 20px; font-weight: 950; }
.compare-deck-heads .head-b > span { background: var(--compare-b); }
.compare-deck-heads h2 { overflow: hidden; font-size: 20px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.compare-deck-heads p { margin-top: 4px; color: var(--compare-muted); font-size: 12px; font-weight: 700; }
.compare-warnings { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.compare-warnings span { border: 2px solid #111; background: #ffe262; padding: 5px 8px; font-size: 11px; font-weight: 900; }
.compare-summary { display: grid; grid-template-columns: repeat(5, 1fr); border: 3px solid #111; background: #111; gap: 3px; }
.compare-metric { min-width: 0; background: #fff; padding: 14px 16px; }
.compare-metric span { display: block; color: var(--compare-muted); font-size: 11px; font-weight: 900; }
.compare-metric strong { display: block; margin-top: 2px; font-size: 27px; line-height: 1.1; }
.compare-metric.tone-a strong { color: var(--compare-a); }
.compare-metric.tone-b strong { color: var(--compare-b); }
.compare-metadata { border: 3px solid #111; background: #111; }
.metadata-head, .metadata-row { display: grid; grid-template-columns: minmax(130px, .55fr) minmax(0, 1fr) minmax(0, 1fr); gap: 3px; }
.metadata-head { margin-bottom: 3px; }
.metadata-head > *, .metadata-row > * { min-width: 0; background: #fff; padding: 10px 13px; }
.metadata-head strong { color: #fff; text-align: center; }
.metadata-head strong:nth-child(2) { background: var(--compare-a); }
.metadata-head strong:nth-child(3) { background: var(--compare-b); }
.metadata-row { margin-bottom: 3px; }
.metadata-row:last-child { margin-bottom: 0; }
.metadata-row > strong { color: var(--compare-muted); font-size: 11px; }
.metadata-row > span { overflow-wrap: anywhere; font-size: 12px; font-weight: 800; }
.metadata-row a { color: #111; font-weight: 950; text-decoration-thickness: 2px; }
.metadata-empty { color: #999; }

.compare-section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 38px 0 13px; padding-bottom: 9px; border-bottom: 3px solid #111; }
.compare-section-title h2 { font-size: 18px; font-weight: 950; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; font-weight: 900; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 12px; height: 12px; }
.legend-a, .bar-a { background: var(--compare-a); }
.legend-b, .bar-b { background: var(--compare-b); }
.compare-charts { display: grid; grid-template-columns: 1.7fr 1fr 1fr .8fr; border: 3px solid #111; background: #111; gap: 3px; }
.compare-chart { min-width: 0; min-height: 220px; background: #fff; padding: 15px; }
.compare-chart h3 { margin-bottom: 14px; font-size: 12px; font-weight: 950; text-transform: uppercase; }
.curve-bars { display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; height: 160px; }
.curve-column { display: grid; grid-template-rows: 1fr 16px; min-width: 0; gap: 5px; text-align: center; font-size: 10px; font-weight: 900; }
.curve-pair { display: flex; align-items: end; justify-content: center; gap: 2px; min-height: 0; border-bottom: 1px solid #aaa; }
.curve-pair i { position: relative; width: min(11px, 45%); min-height: 2px; }
.curve-pair b { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 9px; font-style: normal; }
.spread-row { margin-bottom: 13px; }
.spread-row > span { display: block; margin-bottom: 4px; color: var(--compare-muted); font-size: 10px; font-weight: 900; }
.spread-values { display: grid; gap: 3px; }
.spread-values > div { position: relative; height: 16px; background: #ededed; }
.spread-values i { display: block; height: 100%; min-width: 2px; }
.spread-values b { position: absolute; top: 1px; right: 4px; font-size: 10px; }
.craft-chart div { display: flex; align-items: baseline; justify-content: space-between; padding: 15px 0; border-bottom: 2px solid #111; }
.craft-chart div span { font-size: 13px; font-weight: 950; }
.craft-chart div:first-of-type span, .craft-chart div:first-of-type strong { color: var(--compare-a); }
.craft-chart div:last-child span, .craft-chart div:last-child strong { color: var(--compare-b); }
.craft-chart strong { font-size: 22px; }

.difference-title { align-items: end; }
.compare-row-actions { display: flex; align-items: center; gap: 10px; }
.compare-segments { display: flex; border: 2px solid #111; }
.compare-segments button { min-height: 34px; border: 0; border-right: 2px solid #111; background: #fff; padding: 6px 10px; color: #111; font-size: 11px; font-weight: 900; cursor: pointer; }
.compare-segments button:last-child { border-right: 0; }
.compare-segments button.active { background: #111; color: #fff; }
.compare-share { min-height: 36px; box-shadow: none; padding: 6px 10px; font-size: 11px; }
.compare-table-head { display: grid; grid-template-columns: 52px minmax(0, 1fr) 48px 52px; align-items: center; padding: 0 12px 7px; color: var(--compare-muted); font-size: 10px; font-weight: 950; text-align: center; }
.compare-table-head span:nth-child(2) { text-align: left; }
.compare-card-row { display: grid; grid-template-columns: 40px 56px minmax(0, 1fr) 48px 40px; align-items: center; min-height: 62px; margin-bottom: 5px; border: 2px solid #111; background: #fff; color: #111; text-decoration: none; overflow: hidden; }
.compare-card-row:hover { transform: translateX(2px); }
.compare-card-row.added { border-left: 7px solid var(--compare-b); }
.compare-card-row.removed { border-left: 7px solid var(--compare-a); }
.compare-card-row.same { border-left: 7px solid #999; }
.compare-card-row img, .row-image-fallback { width: 56px; height: 60px; object-fit: cover; background: #ddd; }
.row-image-fallback { display: grid; place-items: center; font-weight: 950; }
.row-count, .row-delta { text-align: center; font-size: 16px; font-weight: 950; }
.count-a { color: var(--compare-a); }
.count-b { color: var(--compare-b); }
.compare-card-row.added .row-delta { color: var(--compare-b); }
.compare-card-row.removed .row-delta { color: var(--compare-a); }
.row-card { min-width: 0; padding: 0 12px; }
.row-card strong, .row-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-card strong { font-size: 13px; }
.row-card small { margin-top: 3px; color: var(--compare-muted); font-size: 10px; }
.compare-no-rows { border: 2px solid #111; background: #fff; padding: 28px; color: var(--compare-muted); text-align: center; font-size: 13px; font-weight: 800; }

@media (max-width: 950px) {
  .compare-inputs { grid-template-columns: 1fr 42px 1fr; }
  .compare-submit { grid-column: 1 / -1; }
  .compare-charts { grid-template-columns: 1fr 1fr; }
  .compare-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .compare-shell { width: min(100% - 20px, 1240px); padding-top: 22px; }
  .compare-heading { align-items: start; }
  .compare-heading h1 { font-size: 34px; }
  .compare-back { padding: 7px 9px; font-size: 11px; }
  .compare-inputs { grid-template-columns: 1fr; gap: 8px; }
  .compare-swap { justify-self: center; transform: rotate(90deg); }
  .compare-submit { grid-column: auto; }
  .compare-deck-heads { grid-template-columns: 1fr; gap: 12px; }
  .compare-summary { grid-template-columns: repeat(2, 1fr); }
  .compare-summary .compare-metric:last-child { grid-column: 1 / -1; }
  .compare-metric strong { font-size: 23px; }
  .compare-charts { grid-template-columns: 1fr; }
  .compare-chart { min-height: 0; }
  .curve-chart { min-height: 220px; }
  .difference-title { display: block; }
  .compare-row-actions { align-items: stretch; flex-direction: column; margin-top: 10px; }
  .compare-segments { width: 100%; }
  .compare-segments button { flex: 1; }
  .compare-card-row { grid-template-columns: 34px 48px minmax(0, 1fr) 38px 34px; }
  .compare-card-row img, .row-image-fallback { width: 48px; height: 56px; }
  .row-card { padding: 0 8px; }
  .compare-table-head { grid-template-columns: 42px minmax(0, 1fr) 38px 38px; }
  .metadata-head, .metadata-row { grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr); }
  .metadata-head > *, .metadata-row > * { padding: 8px 6px; }
}
