:root {
  --bg: #13151b;
  --bg-elevated: #1a1d26;
  --surface: #1f2430;
  --surface-raised: #262c3a;
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(232, 168, 124, 0.28);
  --text: #eceae6;
  --text-soft: #c5c2ba;
  --muted: #848994;
  --warm: #e8a87c;
  --warm-light: #f5d4b8;
  --warm-dim: rgba(232, 168, 124, 0.16);
  --cool: #7eb8da;
  --cool-light: #b8d8ef;
  --cool-dim: rgba(126, 184, 218, 0.14);
  --green: #8fd4a8;
  --green-dim: rgba(95, 180, 130, 0.14);
  --gold: #e8c98a;
  --gold-dim: rgba(232, 201, 138, 0.14);
  --del-bg: rgba(224, 154, 144, 0.18);
  --del-text: #f0b8b0;
  --add-bg: rgba(143, 212, 168, 0.18);
  --add-text: #b8efcc;
  --change-bg: rgba(232, 201, 138, 0.12);
  --shadow-panel: 0 20px 44px rgba(0, 0, 0, 0.32), 0 0 0 1px var(--border);
  --radius: 16px;
  --radius-sm: 10px;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  --nav-h: 64px;
}

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

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 55% 40% at 10% 0%, var(--warm-dim), transparent 58%),
    radial-gradient(ellipse 45% 35% at 90% 5%, var(--cool-dim), transparent 55%),
    radial-gradient(ellipse 50% 35% at 50% 100%, var(--gold-dim), transparent);
}

/* —— Nav —— */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  backdrop-filter: blur(16px) saturate(140%);
  background: rgba(19, 21, 27, 0.78);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.nav-logo {
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand-accent {
  color: var(--warm);
}

.brand-name {
  color: var(--gold);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link-featured {
  color: var(--cool-light);
  border: 1px solid rgba(126, 184, 218, 0.28);
  background: rgba(126, 184, 218, 0.08);
}

.nav-link-green {
  color: #8fd4a8;
  border-color: rgba(95, 180, 130, 0.32);
  background: rgba(95, 180, 130, 0.1);
}

.nav-link-gold {
  color: var(--gold);
  border-color: rgba(232, 201, 138, 0.32);
  background: rgba(232, 201, 138, 0.1);
}

.nav-link-featured.is-active,
.nav-link-green.is-active,
.nav-link-gold.is-active {
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.nav-link-featured.is-active {
  background: rgba(126, 184, 218, 0.22);
  border-color: rgba(126, 184, 218, 0.42);
}

.nav-link-green.is-active {
  background: rgba(95, 180, 130, 0.22);
  border-color: rgba(95, 180, 130, 0.42);
}

.nav-link-gold.is-active {
  background: rgba(232, 201, 138, 0.22);
  border-color: rgba(232, 201, 138, 0.42);
}

.nav-link-icon {
  font-size: 0.9rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--text-soft);
  border-radius: 2px;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

.page-head {
  text-align: center;
  margin-bottom: 1.25rem;
}

.page-badge {
  display: inline-block;
  margin: 0 0 0.65rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 201, 138, 0.28);
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
}

.page-title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.75rem, 4vw, 2.3rem);
  font-weight: 800;
}

.page-desc {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.seg {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.seg-btn {
  padding: 0.35rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.seg-btn.is-active {
  background: var(--warm-dim);
  color: var(--warm-light);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  cursor: pointer;
}

.check input {
  accent-color: var(--warm);
}

.toolbar-actions {
  margin-left: auto;
}

.btn-ghost {
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.16);
}

.editors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 180px;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--surface), var(--bg-elevated));
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-panel.is-dragover {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--warm-dim);
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.editor-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-soft);
  letter-spacing: 0.04em;
}

.upload-btn {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(126, 184, 218, 0.28);
  background: rgba(126, 184, 218, 0.08);
  color: var(--cool-light);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.upload-btn:hover {
  background: rgba(126, 184, 218, 0.16);
}

.file-name {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

.editor {
  flex: 1;
  min-height: 140px;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.editor:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--warm-dim);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stat strong {
  font-weight: 700;
}

.stat-equal strong {
  color: var(--text-soft);
}

.stat-remove strong {
  color: var(--del-text);
}

.stat-add strong {
  color: var(--add-text);
}

.stat-change strong {
  color: var(--gold);
}

.diff-wrap {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.diff-scroll-hint {
  margin: 0;
  padding: 0.35rem 0.85rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.diff-empty {
  margin: 0;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.diff-body {
  display: flex;
  align-items: stretch;
  height: min(70vh, 640px);
  max-height: min(70vh, 640px);
  min-height: 220px;
  overflow: hidden;
}

.diff-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.diff-map-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: 2.4rem;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
}

.diff-map-legend {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.15rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.legend-item {
  line-height: 1;
}

.legend-remove {
  color: var(--del-text);
}

.legend-add {
  color: var(--add-text);
}

.legend-change {
  color: var(--gold);
}

.diff-map {
  flex: 1;
  min-height: 0;
  padding: 0 0.35rem;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.diff-map::-webkit-scrollbar {
  display: none;
}

.diff-map-inner {
  position: relative;
  width: 100%;
}

.diff-map-marker {
  position: absolute;
  left: 0;
  right: 0;
  padding: 0;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s, transform 0.15s;
}

.diff-map-marker:hover {
  opacity: 1;
  transform: scaleX(1.15);
  z-index: 1;
}

.diff-map-equal {
  background: rgba(255, 255, 255, 0.06);
}

.diff-map-remove {
  background: var(--del-text);
}

.diff-map-add {
  background: var(--add-text);
}

.diff-map-change {
  background: var(--gold);
}

.toolbar-nav {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

.diff-nav-pos {
  min-width: 3.2rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.btn-ghost:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.diff-row-active .diff-line-remove,
.diff-row-active .diff-line-add,
.diff-row-active .diff-line-change {
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.12);
}

.diff-row.is-current {
  outline: 2px solid var(--warm);
  outline-offset: -2px;
  z-index: 1;
}

.diff-row-ellipsis {
  background: rgba(255, 255, 255, 0.03);
}

.diff-line-ellipsis {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.diff-gutter-empty {
  background: rgba(0, 0, 0, 0.12);
}

.diff-view {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
}

.diff-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.diff-unified {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--warm-dim) transparent;
}

.diff-col {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--warm-dim) transparent;
}

.diff-col::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.diff-col::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--warm-dim);
}

.diff-col:last-child {
  border-right: none;
}

.diff-unified::-webkit-scrollbar {
  width: 8px;
}

.diff-unified::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--warm-dim);
}

.diff-row {
  display: flex;
  min-height: 1.55em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.diff-row-unified .diff-line {
  flex: 1;
}

.diff-gutter {
  flex-shrink: 0;
  width: 2.8rem;
  padding: 0 0.45rem;
  text-align: right;
  color: var(--muted);
  user-select: none;
  background: rgba(0, 0, 0, 0.18);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  line-height: 1.55;
}

.diff-gutter-remove {
  color: var(--del-text);
  background: rgba(224, 154, 144, 0.08);
}

.diff-gutter-add {
  color: var(--add-text);
  background: rgba(143, 212, 168, 0.08);
}

.diff-gutter-change {
  color: var(--gold);
}

.diff-line {
  flex: 1;
  min-width: 0;
  padding: 0 0.65rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line code {
  font-family: inherit;
}

.diff-line-equal {
  background: transparent;
}

.diff-line-remove {
  background: var(--del-bg);
  color: var(--del-text);
}

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

.diff-line-change {
  background: var(--change-bg);
}

.diff-line-empty {
  background: rgba(255, 255, 255, 0.02);
}

.ch-del {
  background: rgba(224, 154, 144, 0.35);
  border-radius: 2px;
}

.ch-add {
  background: rgba(143, 212, 168, 0.35);
  border-radius: 2px;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.site-footer-link {
  font-size: 0.75rem;
  color: var(--warm-light);
}

.site-footer-tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

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

  .diff-split {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .diff-col {
    max-height: 45vh;
    min-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .diff-col:last-child {
    border-bottom: none;
  }

  .diff-unified {
    height: auto;
    max-height: 60vh;
    min-height: 220px;
  }

  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .diff-body {
    height: auto;
    max-height: none;
    flex-direction: column;
  }

  .diff-split {
    height: auto;
    max-height: none;
  }

  .diff-unified {
    height: auto;
    max-height: 60vh;
    min-height: 220px;
  }

  .diff-map-wrap {
    flex: 0 0 2.4rem;
    width: 100%;
    height: 2.4rem;
    max-height: 2.4rem;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .diff-map-legend {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 0 0.5rem;
    order: 2;
  }

  .diff-map {
    order: 1;
    padding: 0.35rem 0.5rem;
  }

  .diff-map-marker:hover {
    transform: scaleY(1.2);
  }
}

@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1.25rem;
    background: rgba(19, 21, 27, 0.96);
    border-bottom: 1px solid var(--border);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s;
  }

  .nav-menu.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-link {
    justify-content: center;
  }
}
