:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --ink: #1d2522;
  --muted: #65736b;
  --line: #cdd8cf;
  --panel: #ffffff;
  --accent: #18756c;
  --accent-strong: #0f514d;
  --danger: #a73a3a;
  --code: #101615;
  --removed: #ffecec;
  --removed-ink: #8f1d1d;
  --added: #e9f8ee;
  --added-ink: #166534;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

p {
  max-width: 700px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.ghost,
button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button:hover {
  background: var(--accent-strong);
}

.ghost,
.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
}

.ghost:hover,
.secondary:hover,
.view-toggle.active {
  background: #eef4ef;
}

.view-toggle.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.panels {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

.file-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dropzone {
  min-width: 0;
  min-height: 132px;
  border: 1px dashed #8fa59b;
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 10px;
  background: #f9fbf9;
  overflow: hidden;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.dropzone.dragging {
  background: #edf8f3;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 117, 108, 0.16);
}

.dropzone.compact {
  min-height: 108px;
}

.dropzone span {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: 700;
}

input[type="file"] {
  width: 100%;
  min-width: 0;
  color: var(--muted);
}

.dropzone input[type="file"] {
  color: transparent;
}

.dropzone input[type="file"]::file-selector-button {
  max-width: 100%;
  margin-right: 8px;
  color: var(--ink);
}

.result-panel {
  min-height: 420px;
  overflow: hidden;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status {
  min-height: 42px;
  padding: 12px 18px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.status.error {
  color: var(--danger);
}

pre {
  min-height: 340px;
  max-height: 62vh;
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: var(--code);
  color: #dfeee7;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.diff-view {
  background: #fbfdfb;
}

.diff-header {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.diff-file {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  font-weight: 800;
}

.diff-file.left {
  background: #fff6f6;
  color: var(--removed-ink);
}

.diff-file.right {
  background: #f2fbf5;
  color: var(--added-ink);
}

.diff-mark {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid currentColor;
  flex: 0 0 auto;
}

.diff-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-item {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px 18px;
  background: #fff;
}

.summary-item strong {
  font-size: 22px;
  line-height: 1;
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
}

.diff-list {
  max-height: 62vh;
  overflow: auto;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.diff-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.diff-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.diff-block-title {
  padding: 10px 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.diff-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.diff-line {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(54px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.diff-line.removed {
  background: var(--removed);
  color: var(--removed-ink);
}

.diff-line.added {
  background: var(--added);
  color: var(--added-ink);
}

.line-marker,
.line-cell {
  font-weight: 900;
}

.line-value {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.metadata-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.metadata-box {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
}

.metadata-box.left {
  background: #fffafa;
}

.metadata-box.right {
  background: #f8fdf9;
}

.metadata-box span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.color-chip {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #9aa79f;
  flex: 0 0 auto;
}

.color-chip.empty {
  background:
    linear-gradient(45deg, transparent 46%, #9aa79f 48%, #9aa79f 52%, transparent 54%),
    #fff;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .topbar,
  .result-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .panels,
  .file-grid,
  .diff-header,
  .diff-row,
  .metadata-row {
    grid-template-columns: 1fr;
  }

  .diff-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ghost,
  button {
    width: 100%;
  }
}
