:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dce3ed;
  --soft: #f5f7fb;
  --blue: #1769e0;
  --blue-dark: #0e4ca8;
  --green: #147a55;
  --green-soft: #eaf8f1;
  --red: #c9362b;
  --red-soft: #fff0ee;
  --amber: #a86609;
  --amber-soft: #fff7e7;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: 40px 20px 70px; color: var(--ink); background: #eef2f7; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.compare-app { width: min(1320px, 100%); margin: 0 auto; display: grid; gap: 18px; }

.toolbar, .text-panel, .summary, .result-section {
  border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(23, 32, 51, .05);
}
.toolbar { padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.mode-options { display: flex; flex: 0 0 auto; gap: 9px; }
.mode-button {
  width: 116px; min-height: 44px; padding: 8px 10px; border: 1px solid #cbd6e4; border-radius: 10px;
  color: #43516a; background: #fff; font-size: 14px; font-weight: 750;
}
.mode-button:hover { border-color: #79a5e4; color: var(--blue); background: #f5f9ff; }
.mode-button.active { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 5px 14px rgba(23, 105, 224, .2); }
.compare-options { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.compare-options label { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; color: #43516a; background: var(--soft); font-size: 13px; }
.compare-options input { accent-color: var(--blue); }

.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.text-panel { padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel-heading label { font-size: 15px; font-weight: 800; }
.panel-heading span { color: var(--muted); font-size: 12px; }
textarea {
  width: 100%; min-height: 300px; padding: 15px; resize: vertical; border: 1px solid #cbd3df; border-radius: 11px;
  color: var(--ink); background: #fbfcfe; font: 14px/1.75 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "PingFang SC", monospace;
}
textarea:focus { outline: 3px solid rgba(23, 105, 224, .12); border-color: var(--blue); background: #fff; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions button { min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px; font-size: 14px; font-weight: 750; }
.primary-button { color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: var(--ink); background: #dfe7f2; }
.secondary-button:hover { background: #d2ddea; }
.text-button { color: var(--red); background: transparent; }
.actions button:disabled { opacity: .45; cursor: not-allowed; }

.summary { display: grid; grid-template-columns: repeat(4, 130px) 1fr; gap: 10px; padding: 16px; }
.summary article { padding: 11px 13px; border-radius: 10px; background: var(--soft); }
.summary article span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.summary article strong { font-size: 22px; }
.summary .added-stat { background: var(--green-soft); }
.summary .added-stat strong { color: var(--green); }
.summary .deleted-stat { background: var(--red-soft); }
.summary .deleted-stat strong { color: var(--red); }
.summary .changed-stat { background: var(--amber-soft); }
.summary .changed-stat strong { color: var(--amber); }
.summary p { align-self: center; margin: 0; padding-left: 8px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.result-section { overflow: hidden; }
.result-heading { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: var(--soft); }
.result-heading div { padding: 12px 16px; font-size: 14px; font-weight: 800; }
.result-heading div + div { border-left: 1px solid var(--line); }
.legend { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 3px; }
.legend.deleted { background: #ef7770; }
.legend.added { background: #58b58d; }
.result-content { max-height: 620px; overflow: auto; font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "PingFang SC", monospace; }
.diff-row { display: grid; grid-template-columns: 1fr 1fr; min-width: 760px; border-bottom: 1px solid #edf0f4; }
.diff-cell { min-width: 0; display: grid; grid-template-columns: 52px minmax(0, 1fr); white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-cell + .diff-cell { border-left: 1px solid var(--line); }
.line-number { padding: 6px 9px; color: #98a2b3; background: #f7f8fa; text-align: right; user-select: none; }
.line-text { min-height: 34px; padding: 6px 11px; }
.diff-row.deleted .left-cell, .diff-row.changed .left-cell { background: var(--red-soft); }
.diff-row.added .right-cell, .diff-row.changed .right-cell { background: var(--green-soft); }
.diff-row.equal .line-text { color: #475467; }
.inline-result { display: grid; grid-template-columns: 1fr 1fr; min-width: 760px; }
.inline-column { min-height: 220px; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.inline-column + .inline-column { border-left: 1px solid var(--line); }
.token-delete { color: #9f251d; background: #ffd8d4; text-decoration: line-through; }
.token-add { color: #08643f; background: #ccefdc; }
.hidden { display: none !important; }
.empty-result { padding: 44px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 15px); padding: 11px 16px; border-radius: 10px; color: #fff; background: var(--ink); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  body { padding: 18px 12px 50px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .mode-options { overflow-x: auto; }
  .compare-options { justify-content: flex-start; }
  .input-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .summary p { grid-column: 1 / -1; padding: 4px 0 0; }
}
