:root {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-elevated: rgba(18, 24, 38, 0.82);
  --panel: rgba(15, 19, 31, 0.9);
  --panel-soft: rgba(22, 28, 42, 0.82);
  --line: rgba(162, 184, 255, 0.16);
  --line-strong: rgba(162, 184, 255, 0.3);
  --text: #edf2ff;
  --muted: #9da9c7;
  --accent: #88f7d4;
  --accent-strong: #67d6ff;
  --same: rgba(136, 247, 212, 0.16);
  --replace: rgba(255, 199, 92, 0.16);
  --delete: rgba(255, 121, 121, 0.16);
  --insert: rgba(103, 214, 255, 0.16);
  --same-pill: #88f7d4;
  --replace-pill: #ffc75c;
  --delete-pill: #ff8b8b;
  --insert-pill: #67d6ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-family: var(--sans);
  line-height: 1.5;
  font-weight: 400;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(103, 214, 255, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(136, 247, 212, 0.14), transparent 22%),
    linear-gradient(160deg, #0a0c12 0%, #111724 48%, #0c1017 100%);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
textarea,
input {
  font: inherit;
}

#app {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.app-shell {
  display: grid;
  gap: 20px;
}

.hero-panel,
.toolbar,
.editor-card,
.result-card {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 24px;
  padding: 36px;
  border-radius: var(--radius-xl);
}

.eyebrow,
.card-label {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.8rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
  max-width: 10ch;
}

h2 {
  font-size: 1.25rem;
}

.hero-copy {
  max-width: 62ch;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: flex-end;
  gap: 12px;
}

.button,
.upload-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.button:hover,
.upload-button span:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #051018;
}

.button-secondary {
  background: rgba(162, 184, 255, 0.12);
  color: var(--text);
  border-color: var(--line-strong);
}

.button-ghost,
.upload-button span {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
}

.toolbar-hint {
  flex: 1 1 280px;
  color: var(--muted);
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.summary-text {
  color: var(--muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.editor-card,
.result-card {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.card-head,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.result-tools {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.upload-button {
  position: relative;
  overflow: hidden;
}

.file-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.7;
}

textarea:focus-visible,
.button:focus-visible,
.upload-button input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.filter-chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(162, 184, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.filter-chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent-strong);
}

.filter-chip.is-active {
  background: rgba(136, 247, 212, 0.14);
  color: var(--text);
  border-color: rgba(136, 247, 212, 0.5);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.legend-item,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.same {
  background: var(--same);
  color: var(--same-pill);
}

.replace {
  background: var(--replace);
  color: var(--replace-pill);
}

.delete {
  background: var(--delete);
  color: var(--delete-pill);
}

.insert {
  background: var(--insert);
  color: var(--insert-pill);
}

.diff-table {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.diff-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 88px 88px minmax(0, 1fr);
  align-items: stretch;
}

.diff-row > div {
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.diff-row-header {
  background: rgba(162, 184, 255, 0.08);
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diff-body {
  background: rgba(8, 10, 16, 0.28);
}

.line-number {
  color: var(--muted);
  font-family: var(--mono);
}

.line-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
}

.blank-line {
  color: var(--muted);
  font-style: italic;
}

.diff-row-equal {
  background: rgba(255, 255, 255, 0.02);
}

.diff-row-replace {
  background: linear-gradient(90deg, var(--replace) 0%, rgba(255, 199, 92, 0.06) 100%);
}

.diff-row-delete {
  background: linear-gradient(90deg, var(--delete) 0%, rgba(255, 121, 121, 0.04) 100%);
}

.diff-row-insert {
  background: linear-gradient(90deg, var(--insert) 0%, rgba(103, 214, 255, 0.04) 100%);
}

.status-equal {
  background: var(--same);
  color: var(--same-pill);
}

.status-replace {
  background: var(--replace);
  color: var(--replace-pill);
}

.status-delete {
  background: var(--delete);
  color: var(--delete-pill);
}

.status-insert {
  background: var(--insert);
  color: var(--insert-pill);
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  #app {
    width: min(100vw - 24px, 1280px);
    padding-top: 12px;
  }

  .hero-panel,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    padding: 24px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-tools,
  .filter-group {
    justify-items: start;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .result-card,
  .editor-card,
  .toolbar {
    padding: 16px;
  }

  .diff-table {
    overflow-x: auto;
  }

  .diff-row {
    min-width: 760px;
  }

  textarea {
    min-height: 280px;
  }
}
