:root {
  --ink: var(--tools-text);
  --muted: var(--tools-muted);
  --paper: var(--tools-bg);
  --surface: var(--tools-surface);
  --surface-soft: var(--tools-surface-soft);
  --line: var(--tools-line);
  --green: var(--tools-green);
  --green-strong: var(--tools-green-strong);
  --green-soft: var(--tools-green-soft);
  --green-text: var(--tools-green-text);
  --red: var(--tools-red);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--tools-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
[v-cloak] { display: none; }
.file-input-hidden { display: none; }
.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

main {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
}
.hero {
  max-width: 850px;
  margin: 42px auto 54px;
  text-align: center;
}
.eyebrow, .step-label {
  margin: 0 0 12px;
  color: var(--green-strong);
  font: 700 .72rem/1.3 var(--tools-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0 auto;
  font-family: var(--tools-serif);
  font-size: clamp(2.65rem, 6vw, 4.8rem);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.055em;
}
.hero-copy {
  max-width: 690px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.13rem);
  line-height: 1.7;
}
.hero-proof {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px 20px;
  margin: 22px 0 0;
  padding: 0;
  color: var(--green-strong);
  font-size: .78rem;
  font-weight: 750;
  list-style: none;
}
.hero-proof li { display: inline-flex; align-items: center; gap: 6px; }
.hero-proof svg { width: 14px; height: 14px; flex: 0 0 auto; }

.workspace {
  margin-bottom: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--tools-shadow);
}
.workspace-heading {
  padding: clamp(24px, 5vw, 44px) clamp(20px, 5vw, 46px) 18px;
}
.workspace h2, .workspace h3 {
  margin: 0;
  font-family: var(--tools-serif);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.04em;
}
.workspace h2 { font-size: clamp(1.95rem, 4vw, 2.75rem); }
.workspace h3 { font-size: clamp(1.12rem, 2.3vw, 1.45rem); }
.workspace-heading > p:not(.step-label) {
  max-width: 760px;
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.editors-grid {
  padding: 0 clamp(20px, 5vw, 46px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.editor-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}
.editor-heading {
  min-height: 78px;
  padding: 15px 16px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.editor-heading > div { min-width: 0; }
.editor-heading h3 {
  font-family: var(--tools-sans);
  font-size: .94rem;
  font-weight: 800;
  letter-spacing: -.015em;
}
.editor-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.45;
}
.line-count {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font: 700 .65rem/1.2 var(--tools-mono);
}
.editor-card textarea {
  display: block;
  width: 100%;
  min-height: 245px;
  resize: vertical;
  padding: 15px 16px;
  border: 0;
  border-block: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font: 500 .82rem/1.55 var(--tools-mono);
  tab-size: 4;
  white-space: pre-wrap;
}
.editor-card textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.editor-card textarea:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--green) 34%, transparent);
}
.editor-actions {
  min-height: 62px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.editor-actions > span {
  min-width: 0;
  color: var(--muted);
  font-size: .66rem;
  line-height: 1.35;
}

.primary-button, .secondary-button, .destructive-quiet-button, .view-toggle button, .fold-control button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 780;
  line-height: 1.2;
}
.primary-button, .secondary-button, .destructive-quiet-button {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-button {
  border: 1px solid var(--tools-action);
  color: var(--tools-on-action);
  background: var(--tools-action);
}
.primary-button:hover:not(:disabled) { background: var(--tools-action-hover); border-color: var(--tools-action-hover); }
.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}
.secondary-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); background: var(--green-soft); }
.destructive-quiet-button {
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line));
  color: var(--red);
  background: var(--surface);
}
.destructive-quiet-button:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 9%, var(--surface)); }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; flex: 0 0 auto; }
.compact-button { min-height: 38px; padding-inline: 11px; font-size: .72rem; }
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 40%, transparent);
  outline-offset: 2px;
}

.input-toolbar {
  padding: 13px clamp(20px, 5vw, 46px) 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comparison-options {
  margin: 24px clamp(20px, 5vw, 46px) 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}
.comparison-options legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 800;
}
.option-check, .option-radio {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.option-check { margin-bottom: 14px; }
.option-check input, .option-radio input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex: 0 0 auto;
  accent-color: var(--green-strong);
}
.option-check strong, .option-check small, .option-radio strong, .option-radio small { display: block; }
.option-check strong, .option-radio strong { font-size: .78rem; }
.option-check small, .option-radio small { margin-top: 3px; color: var(--muted); font-size: .69rem; line-height: 1.45; }
.whitespace-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.option-radio {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.option-radio.selected {
  border-style: double;
  border-color: var(--green-strong);
  background: var(--green-soft);
}
.normalization-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .69rem;
  line-height: 1.5;
}

.result-section {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.result-heading {
  padding: 26px clamp(20px, 5vw, 46px) 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.result-heading .step-label { margin-bottom: 8px; }
.view-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.view-toggle button {
  min-width: 116px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: .72rem;
}
.view-toggle button[aria-pressed="true"] {
  color: var(--green-text);
  background: var(--surface);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--ink) 8%, transparent);
}

.status-card {
  margin: 0 clamp(20px, 5vw, 46px);
  padding: 15px 16px;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}
.status-card strong { display: block; font-size: .86rem; }
.status-card p { margin: 4px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.status-shape {
  width: 12px;
  height: 12px;
  margin-top: 3px;
  border: 2px solid var(--muted);
}
.state-empty .status-shape { border-radius: 50%; }
.state-identical .status-shape { border-radius: 50%; border-color: var(--green-strong); background: var(--green-soft); }
.state-equivalent .status-shape { transform: rotate(45deg); border-color: var(--green-strong); background: var(--green-soft); }
.state-changed .status-shape { border-color: var(--red); border-radius: 2px; }

.processing-row, .error-panel, .detail-notice {
  margin: 12px clamp(20px, 5vw, 46px) 0;
  border-radius: 12px;
}
.processing-row {
  min-height: 54px;
  padding: 8px 10px 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .73rem;
}
.processing-row .compact-button { margin-left: auto; }
.error-panel .compact-button, .retry-notice .compact-button { margin-top: 8px; }
.busy-indicator {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--green-strong);
  border-radius: 50%;
  animation: compare-spin .8s linear infinite;
}
@keyframes compare-spin { to { transform: rotate(360deg); } }
.error-panel {
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--red) 55%, var(--line));
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
}
.error-panel strong { color: var(--red); font-size: .8rem; }
.error-panel p { margin: 4px 0 0; font-size: .72rem; line-height: 1.5; }
.detail-notice {
  padding: 10px 13px;
  border: 1px dashed var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .69rem;
  line-height: 1.5;
}
.detail-notice p { margin: 0; }
.detail-notice p + p { margin-top: 4px; }

.diff-key {
  margin: 18px clamp(20px, 5vw, 46px) 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 740;
}
.diff-key > span { display: inline-flex; align-items: center; gap: 6px; }
.key-shape { width: 10px; height: 10px; display: inline-block; border: 2px solid currentColor; }
.key-shape.removed { color: var(--red); border-radius: 2px; }
.key-shape.added { color: var(--green-strong); border-radius: 50%; }
.key-shape.ignored { color: var(--muted); transform: rotate(45deg); border-style: dashed; }

.diff-output {
  margin: 0 clamp(20px, 5vw, 46px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.diff-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.diff-row:last-child { border-bottom: 0; }
.diff-cell {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  background: var(--surface);
}
.diff-cell + .diff-cell { border-left: 1px solid var(--line); }
.diff-cell.empty { min-height: 43px; background: var(--surface-soft); }
.line-number {
  padding: 10px 7px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font: 600 .64rem/1.55 var(--tools-mono);
  text-align: right;
  user-select: none;
}
.line-content {
  min-width: 0;
  min-height: 43px;
  padding: 7px 9px 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 5px 8px;
}
.line-content code, .unified-line code {
  min-width: 0;
  min-height: 1.45em;
  color: var(--ink);
  font: 500 .72rem/1.55 var(--tools-mono);
  overflow-wrap: anywhere;
  tab-size: 4;
  white-space: pre-wrap;
}
.change-label {
  min-height: 24px;
  padding: 3px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-size: .59rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.change-label.removed { color: var(--red); border-radius: 3px; }
.change-label.added { color: var(--green-text); border-radius: 999px; }
.change-label.ignored { color: var(--muted); border-style: dashed; transform: none; }
.eol-note {
  grid-column: 2;
  color: var(--muted);
  font: 650 .6rem/1.35 var(--tools-mono);
}
.word-change {
  margin: 0;
  padding: 0 1px;
  color: inherit;
  border-radius: 2px;
}
.word-change.removed {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--red) 80%, transparent);
  text-decoration-thickness: 1px;
}
.word-change.added {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  box-shadow: inset 0 -2px color-mix(in srgb, var(--green-strong) 65%, transparent);
}
.is-deletion .left-cell, .is-modified .left-cell { background: color-mix(in srgb, var(--red) 4%, var(--surface)); }
.is-insertion .right-cell, .is-modified .right-cell { background: color-mix(in srgb, var(--green) 5%, var(--surface)); }
.is-ignored .diff-cell { border-top: 1px dashed color-mix(in srgb, var(--muted) 50%, var(--line)); background: var(--surface-soft); }

.fold-control {
  min-height: 48px;
  padding: 5px 8px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}
.fold-control button {
  max-width: 100%;
  padding: 0 13px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: .68rem;
}
.fold-control button:hover { color: var(--green-text); border-color: var(--green); }
.fold-more { border-top: 1px solid var(--line); }

.unified-row { border-bottom: 1px solid var(--line); }
.unified-row:last-child { border-bottom: 0; }
.unified-line {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 8px 82px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 9px 10px 9px 8px;
}
.unified-line + .unified-line { border-top: 1px dashed var(--line); }
.unified-marker {
  width: 7px;
  height: 22px;
  margin-top: 1px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
.unified-line.removed .unified-marker { border-color: var(--red); border-radius: 2px; background: color-mix(in srgb, var(--red) 12%, transparent); }
.unified-line.added .unified-marker { border-color: var(--green-strong); border-radius: 999px; background: var(--green-soft); }
.unified-line.ignored .unified-marker { border-color: var(--muted); border-style: dashed; transform: rotate(45deg); }
.unified-line.removed { background: color-mix(in srgb, var(--red) 4%, var(--surface)); }
.unified-line.added { background: color-mix(in srgb, var(--green) 5%, var(--surface)); }
.unified-line.ignored { background: var(--surface-soft); }
.unified-line-number {
  color: var(--muted);
  font: 600 .63rem/1.55 var(--tools-mono);
  white-space: nowrap;
}
.unified-status {
  display: block;
  margin-bottom: 1px;
  font: 800 .55rem/1.2 var(--tools-sans);
  letter-spacing: .01em;
}
.unified-status.removed { color: var(--red); }
.unified-status.added { color: var(--green-text); }
.unified-status.ignored { color: var(--muted); text-decoration: underline dashed; text-underline-offset: 2px; }
.unified-line .eol-note { grid-column: 3 / -1; }

.pagination {
  margin: 13px clamp(20px, 5vw, 46px) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.pagination > span { color: var(--muted); font-size: .69rem; text-align: center; }

.export-bar {
  margin-top: 24px;
  padding: 20px clamp(20px, 5vw, 46px) clamp(25px, 5vw, 36px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}
.export-bar strong { font-size: .82rem; }
.export-bar p { max-width: 590px; margin: 4px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.export-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 24px;
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 15px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--tools-shadow);
  font-size: .74rem;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1040px); }
  .hero { margin: 34px auto 40px; }
  .editors-grid { grid-template-columns: 1fr; }
  .workspace-heading, .editors-grid, .input-toolbar { padding-inline: 16px; }
  .comparison-options, .status-card, .processing-row, .error-panel, .detail-notice, .diff-key, .diff-output, .pagination { margin-inline: 16px; }
  .result-heading { padding-inline: 16px; align-items: stretch; flex-direction: column; }
  .view-toggle { width: 100%; }
  .view-toggle button { min-width: 0; }
  .whitespace-options { grid-template-columns: 1fr; }
  .export-bar { padding-inline: 16px; grid-template-columns: 1fr; }
  .export-actions { justify-content: stretch; }
  .export-actions > button { flex: 1 1 160px; }
}

@media (max-width: 620px) {
  .diff-row { grid-template-columns: 1fr; }
  .diff-cell + .diff-cell { border-left: 0; border-top: 1px dashed var(--line); }
  .is-modified .left-cell, .is-deletion .left-cell { border-left: 3px solid color-mix(in srgb, var(--red) 65%, transparent); }
  .is-modified .right-cell, .is-insertion .right-cell { border-left: 3px solid color-mix(in srgb, var(--green-strong) 65%, transparent); }
  .unified-line { grid-template-columns: 8px 66px minmax(0, 1fr); }
  .unified-line .eol-note { grid-column: 3; }
  .pagination { flex-wrap: wrap; }
}

@media (max-width: 390px) {
  .hero h1 { font-size: clamp(2.25rem, 15vw, 3rem); }
  .workspace { border-radius: 18px; }
  .workspace-heading, .editors-grid, .input-toolbar { padding-inline: 12px; }
  .comparison-options, .status-card, .processing-row, .error-panel, .detail-notice, .diff-key, .diff-output, .pagination { margin-inline: 12px; }
  .result-heading { padding-inline: 12px; }
  .editor-heading { flex-direction: column; }
  .editor-actions { align-items: stretch; flex-direction: column; }
  .editor-actions .secondary-button { width: 100%; }
  .input-toolbar > button { flex: 1 1 130px; }
  .diff-cell { grid-template-columns: 36px minmax(0, 1fr); }
  .line-content { grid-template-columns: 1fr; }
  .change-label { justify-self: start; }
  .eol-note { grid-column: 1; }
  .unified-line { grid-template-columns: 7px 54px minmax(0, 1fr); gap: 6px; }
  .unified-line-number { font-size: .57rem; }
  .export-bar { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .busy-indicator { animation: none; border-color: var(--green-strong); }
}
