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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f6f8fa;
  color: #24292e;
  min-height: 100vh;
}

header {
  background: #24292e;
  color: #fff;
  padding: 16px 24px;
}

header h1 { font-size: 1.25rem; font-weight: 600; }
header p { font-size: 0.85rem; color: #8b949e; margin-top: 2px; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .inputs { grid-template-columns: 1fr; }
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #57606a;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

textarea {
  width: 100%;
  height: 200px;
  padding: 10px 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  resize: vertical;
  background: #fff;
  color: #24292e;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus { border-color: #0969da; box-shadow: 0 0 0 3px rgba(9,105,218,0.1); }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: #57606a;
  cursor: pointer;
  user-select: none;
}

.controls input[type="checkbox"] { cursor: pointer; }

.spacer { flex: 1; }

button {
  padding: 6px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#compareBtn {
  background: #1f883d;
  border-color: rgba(31,136,61,0.4);
  color: #fff;
}

#compareBtn:hover { background: #1a7f37; }

#clearBtn {
  background: #fff;
  border-color: #d0d7de;
  color: #24292e;
}

#clearBtn:hover { background: #f3f4f6; }

.output {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  overflow: hidden;
}

.output:empty::before {
  content: 'Diff output will appear here.';
  display: block;
  padding: 24px;
  color: #8b949e;
  font-size: 0.875rem;
  text-align: center;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.diff-table td { padding: 1px 0; vertical-align: top; white-space: pre-wrap; word-break: break-all; }

.line-num {
  width: 1%;
  min-width: 40px;
  padding: 1px 12px !important;
  text-align: right;
  color: #8b949e;
  user-select: none;
  border-right: 1px solid #d0d7de;
}

.line-prefix {
  width: 20px;
  padding: 1px 4px !important;
  text-align: center;
  user-select: none;
  font-weight: 600;
}

.line-content { padding: 1px 12px !important; }

tr.removed td { background: #ffeef0; color: #cb2431; }
tr.added   td { background: #e6ffed; color: #22863a; }
tr.unchanged td { background: #fff; color: #24292e; }

.word-removed { background: #fdb8c0; border-radius: 2px; }
.word-added   { background: #acf2bd; border-radius: 2px; }

.word-diff-output {
  padding: 16px 20px;
  font-size: 0.9rem;
  line-height: 1.8;
}
.word-diff-output p { margin-bottom: 1em; }
.word-diff-output p:last-child { margin-bottom: 0; }
.word-diff-output .word-removed {
  background: #fdb8c0;
  color: #cb2431;
  text-decoration: line-through;
  border-radius: 2px;
}
.word-diff-output .word-added {
  background: #acf2bd;
  color: #22863a;
  border-radius: 2px;
}

/* Word diff split view */
.word-diff-split {
  display: flex;
}
.word-diff-pane {
  flex: 1;
  padding: 16px 20px;
  font-size: 0.9rem;
  line-height: 1.8;
}
.word-diff-pane p { margin-bottom: 1em; }
.word-diff-pane p:last-child { margin-bottom: 0; }
.word-diff-gutter {
  width: 4px;
  min-width: 4px;
  background: #d0d7de;
}
.word-diff-pane-left .word-removed {
  background: #fdb8c0;
  color: #cb2431;
  text-decoration: line-through;
  border-radius: 2px;
}
.word-diff-pane-right .word-added {
  background: #acf2bd;
  color: #22863a;
  border-radius: 2px;
}

.diff-summary {
  padding: 10px 16px;
  font-size: 0.8125rem;
  color: #57606a;
  border-bottom: 1px solid #d0d7de;
  background: #f6f8fa;
}

.identical-msg {
  padding: 24px;
  text-align: center;
  color: #57606a;
  font-size: 0.875rem;
}

/* Controls separator */
.separator {
  color: #d0d7de;
  user-select: none;
}

/* Split (side-by-side) view */
.diff-table-split { table-layout: fixed; }
.diff-table-split td.line-num { width: 40px; min-width: 40px; }
.diff-table-split td.line-content { width: calc(50% - 42px); }
.diff-table-split td.split-gutter {
  width: 4px;
  min-width: 4px;
  padding: 0 !important;
  background: #d0d7de;
  border-right: none;
}

.split-removed { background: #ffeef0; color: #cb2431; }
.split-added   { background: #e6ffed; color: #22863a; }
.split-unchanged { background: #fff; color: #24292e; }
.split-empty   { background: #f6f8fa; }

.diff-table-split td.line-num.split-removed,
.diff-table-split td.line-num.split-added,
.diff-table-split td.line-num.split-unchanged,
.diff-table-split td.line-num.split-empty {
  border-right: 1px solid #d0d7de;
}
