.workspace .page-header,
.workspace .page-body {
  max-width: 1180px;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: stretch;
}

.compare-grid .panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0;
}

.lined {
  display: flex;
  height: 420px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-input);
  overflow: hidden;
}

.lined:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.lined-gutter {
  margin: 0;
  width: 42px;
  flex-shrink: 0;
  padding: 10px 8px;
  overflow: hidden;
  text-align: right;
  color: var(--color-muted);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  user-select: none;
}

.lined textarea.input {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  resize: none;
  white-space: pre;
  overflow: auto;
  scrollbar-gutter: stable;
}

.lined textarea.input:focus {
  border-color: transparent;
  box-shadow: none;
}

.compare-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.diff-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-input);
  overflow: auto;
  max-height: min(52vh, 520px);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

.diff-split:empty {
  display: none;
}

.diff-split-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px 10px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
}

.diff-cell {
  display: flex;
  min-width: 0;
  min-height: 1.5em;
  overflow-x: auto;
}

.diff-cell.is-del {
  background: var(--color-danger-bg);
}

.diff-cell.is-add {
  background: var(--color-ok-bg);
}

.diff-cell.is-empty {
  background: var(--color-bg);
}

.diff-num {
  flex-shrink: 0;
  width: 36px;
  padding: 0 8px;
  text-align: right;
  color: var(--color-muted);
  user-select: none;
}

.diff-text {
  white-space: pre;
  padding-right: 10px;
}

.diff-mark {
  border-radius: 2px;
  padding: 0 1px;
}

.diff-cell.is-del .diff-mark {
  background: #f0b4b4;
}

.diff-cell.is-add .diff-mark {
  background: #a9dbb8;
}

html[data-theme="dark"] .diff-cell.is-del .diff-mark {
  background: #6e3333;
}

html[data-theme="dark"] .diff-cell.is-add .diff-mark {
  background: #1d5a36;
}

.diff-caption {
  margin-top: var(--space-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.diff-caption[hidden] {
  display: none;
}

.diff {
  margin-top: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-input);
  overflow: auto;
  max-height: min(52vh, 520px);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

.diff:empty {
  display: none;
}

.diff-line {
  display: flex;
  gap: 10px;
  padding: 1px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-gutter {
  flex-shrink: 0;
  width: 14px;
  color: var(--color-muted);
  user-select: none;
}

.diff-line.is-del {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.diff-line.is-add {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

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

  .diff-split {
    grid-template-columns: 1fr;
  }
}
