@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/space-grotesk.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/inter.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono.woff2") format("woff2");
}

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #111823;
  --ink-soft: #5b6675;
  --ink-faint: #8a95a3;
  --line: #e2e7ee;
  --line-strong: #d3dae3;
  --brand: #3b3ad6;
  --brand-ink: #2c2ba8;

  --add-bg: #e7f6ec;
  --add-strong: #0f7a44;
  --add-gutter: #c7ead2;
  --add-word: #a4e4bd;

  --del-bg: #fcecec;
  --del-strong: #bd2f2f;
  --del-gutter: #f1c9c9;
  --del-word: #f4bcbc;

  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", var(--sans);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, #f6f8fb 0%, var(--bg) 55%) fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
header {
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.head-in {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 0;
}
.mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 9px;
  background: var(--ink);
  display: grid; place-items: center;
}
.mark svg { display: block; }
.brand-name {
  font-family: var(--display);
  font-weight: 700; font-size: 19px; letter-spacing: -0.02em;
}
.brand-tag {
  font-size: 12.5px; color: var(--ink-soft); margin-top: -2px;
}
.head-spacer { flex: 1; }
.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 3px 7px; background: var(--surface);
  white-space: nowrap;
}
@media (max-width: 620px){ .kbd { display: none; } }

/* ---------- Input area ---------- */
main { padding: 26px 0 80px; }
.panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 760px){ .panels { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(16,22,31,.04);
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.old { background: var(--del-strong); }
.dot.new { background: var(--add-strong); }
.panel-title {
  font-family: var(--display); font-weight: 600; font-size: 14px;
  letter-spacing: -0.01em;
}
.panel-count { margin-left: auto; font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }
textarea {
  border: 0; resize: vertical;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  padding: 14px; min-height: 240px; width: 100%;
  color: var(--ink); background: transparent;
  outline: none; tab-size: 4;
}
textarea::placeholder { color: var(--ink-faint); }

/* ---------- Controls ---------- */
.controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 18px 0 6px;
}
button {
  font-family: var(--sans); font-weight: 600; font-size: 14px;
  border-radius: 10px; cursor: pointer; border: 1px solid transparent;
  padding: 10px 16px; transition: transform .04s ease, background .15s, border-color .15s;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-faint); }

.ctrl-spacer { flex: 1; }

.opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.opt { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.opt input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }

/* ---------- Results ---------- */
.summary {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin: 24px 0 12px;
}
.summary[hidden] { display: none; }
.summary h2 { font-family: var(--display); font-size: 16px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.chip { font-family: var(--mono); font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }
.chip.add { color: var(--add-strong); background: var(--add-bg); }
.chip.del { color: var(--del-strong); background: var(--del-bg); }
.chip.same { color: var(--ink-soft); background: #eef1f5; }

.view-toggle { margin-left: auto; display: inline-flex; background: #e6eaf0; border-radius: 9px; padding: 3px; }
.view-toggle button {
  padding: 6px 13px; font-size: 13px; border-radius: 7px; background: transparent; color: var(--ink-soft); border: 0;
}
.view-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,22,31,.08); }

.result-shell { position: relative; display: flex; gap: 8px; }
.result {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: auto;
  box-shadow: 0 1px 2px rgba(16,22,31,.04);
}

table.diff { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
table.diff td { vertical-align: top; padding: 0; }
.gutter {
  width: 1%; white-space: nowrap; text-align: right;
  padding: 1px 10px 1px 12px; color: var(--ink-faint);
  user-select: none; border-right: 1px solid var(--line);
  background: #fafbfc; font-size: 12px;
}
.sign { width: 1%; text-align: center; padding: 1px 6px; user-select: none; font-weight: 700; }
.code { padding: 1px 14px 1px 10px; white-space: pre-wrap; word-break: break-word; }

tr.row-eq .code { color: var(--ink); }
tr.row-del { background: var(--del-bg); }
tr.row-del .gutter { background: var(--del-gutter); color: var(--del-strong); border-right-color: var(--del-gutter); }
tr.row-del .sign { color: var(--del-strong); }
tr.row-ins { background: var(--add-bg); }
tr.row-ins .gutter { background: var(--add-gutter); color: var(--add-strong); border-right-color: var(--add-gutter); }
tr.row-ins .sign { color: var(--add-strong); }
tr.row-empty { background: #f7f8fa; }
tr.row-empty .gutter { background: #f0f2f5; border-right-color: var(--line); }

ins.word { background: var(--add-word); text-decoration: none; border-radius: 3px; padding: 0 1px; }
del.word { background: var(--del-word); text-decoration: none; border-radius: 3px; padding: 0 1px; }

/* Side-by-side */
table.split td.cell-old, table.split td.cell-new { width: 50%; }
table.split td.mid { border-right: 1px solid var(--line); }

/* Change rail */
.rail {
  flex: 0 0 12px; border-radius: 8px; background: #e6eaf0; position: relative;
  overflow: hidden;
}
.rail button {
  position: absolute; left: 2px; right: 2px; height: 4px; padding: 0; border: 0; border-radius: 2px; min-height: 0;
  cursor: pointer; background: var(--ink-faint);
}
.rail button.tick-add { background: var(--add-strong); }
.rail button.tick-del { background: var(--del-strong); }
@media (max-width: 620px){ .rail { display: none; } }

/* Empty / identical states */
.state {
  text-align: center; padding: 56px 24px; color: var(--ink-soft);
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.state strong { display: block; color: var(--ink); font-family: var(--display); font-size: 16px; margin-bottom: 4px; font-weight: 600; }
.state.match strong { color: var(--add-strong); }

/* ---------- About / FAQ ---------- */
.about {
  padding: 8px 20px 10px;
  border-top: 1px solid var(--line);
}
.about h2 {
  font-family: var(--display); font-size: 19px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink);
  margin: 34px 0 12px;
}
.about h2:first-child { margin-top: 30px; }
.about p { color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; max-width: 720px; margin: 0 0 10px; }
.about .steps { color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; max-width: 720px; padding-left: 22px; margin: 0; }
.about .steps li { margin-bottom: 6px; }
.about .faq h3 {
  font-family: var(--display); font-size: 15px; font-weight: 600;
  color: var(--ink); margin: 18px 0 6px;
}
.about .faq h3:first-child { margin-top: 0; }

footer { text-align: center; color: var(--ink-faint); font-size: 12.5px; padding: 30px 0 40px; }
