/* ============================================================
   Diff - 简约高级质感（参考 diffchecker.com）
   品牌绿 #00A65A 点缀 | 大量留白 | 极淡 diff 高亮
   ============================================================ */
:root {
  --brand: #00A65A;
  --brand-hover: #008f4d;

  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-hover: #f1f3f5;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  /* diff 极淡高亮（对齐 diffchecker） */
  --add-bg: #e8f5e9;
  --add-strong: #d2e9d4;
  --add-text: #1b5e20;

  --del-bg: #fce8e6;
  --del-strong: #f5d5d2;
  --del-text: #b71c1c;

  --eq-text: #4b5563;

  --linenum-bg: #fafbfc;
  --linenum-text: #b6bcc4;

  --shadow-xs: 0 1px 2px rgba(16,24,40,0.04);
  --shadow-sm: 0 1px 3px rgba(16,24,40,0.06);

  --radius: 8px;
  --radius-sm: 6px;

  --mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  --bg: #111418;
  --bg-subtle: #171b20;
  --bg-hover: #1f242b;
  --border: #262c34;
  --border-strong: #353c46;

  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;

  --add-bg: rgba(0, 166, 90, 0.10);
  --add-strong: rgba(0, 166, 90, 0.18);
  --add-text: #6ee7b7;

  --del-bg: rgba(239, 83, 80, 0.10);
  --del-strong: rgba(239, 83, 80, 0.17);
  --del-text: #fca5a5;

  --eq-text: #aab0bc;

  --linenum-bg: #151920;
  --linenum-text: #4b5563;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ============ 顶部导航（白底细线） ============ */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand .logo { width: 26px; height: 26px; border-radius: 6px; }

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease-out;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.95); }

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ============ 主区 ============ */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 16px;
}

/* ============ 输入区 ============ */
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.pane {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.pane:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 166, 90, 0.08);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.pane-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.pane-tools { display: flex; align-items: center; gap: 4px; }

.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 150ms ease-out;
  font-family: inherit;
}

.tool:hover { background: var(--bg-hover); color: var(--text); }
.tool:active { transform: scale(0.96); }

.linecount {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
}

.pane textarea {
  width: 100%;
  min-height: 240px;
  border: 0;
  outline: none;
  resize: vertical;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  tab-size: 2;
}

.pane textarea::placeholder { color: var(--text-tertiary); }

/* ============ 比较按钮 ============ */
.compare-row {
  display: flex;
  justify-content: center;
  margin: 20px 0 0;
}

.compare-btn {
  appearance: none;
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xs);
  transition: all 150ms ease-out;
  font-family: inherit;
}

.compare-btn:hover { background: var(--brand-hover); }
.compare-btn:active { transform: scale(0.98); }

.compare-btn kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
  background: rgba(255,255,255,0.18);
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  height: 18px;
  box-sizing: border-box;
}

/* ============ 结果区 ============ */
.result { margin: 24px 0 20px; }

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* 分段切换器（简约） */
.seg {
  display: inline-flex;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease-out;
  font-family: inherit;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.seg-btn:active { transform: scale(0.97); }

/* 字符高亮开关 chip */
.toggle-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease-out;
  font-family: inherit;
}

.toggle-chip:hover { border-color: var(--border-strong); color: var(--text); }
.toggle-chip:active { transform: scale(0.97); }

.toggle-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* 内联统计 */
.stats-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.st { font-weight: 600; }
.st-add { color: var(--brand); }
.st-del { color: #d32f2f; }
.st-eq { color: var(--text-tertiary); font-weight: 500; }

.divider-v {
  width: 1px;
  height: 18px;
  background: var(--border);
}

/* 结果主体 */
.result-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: auto;
  max-height: 72vh;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}

.view-split { display: grid; grid-template-columns: 1fr 1fr; min-width: 760px; }
.view-split .col { border-right: 1px solid var(--border); }
.view-split .col:last-child { border-right: 0; }
.view-unified { min-width: 560px; }

/* 行渲染（极简，无色条） */
.dline {
  display: flex;
  min-height: 24px;
  border-bottom: 1px solid var(--border);
}

.dline:last-child { border-bottom: 0; }

.dline .ln {
  flex: 0 0 48px;
  padding: 0 10px;
  text-align: right;
  background: var(--linenum-bg);
  color: var(--linenum-text);
  user-select: none;
  font-size: 11px;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

.dline .lc {
  flex: 1;
  padding: 0 12px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 24px;
}

.dline.add { background: var(--add-bg); color: var(--add-text); }
.dline.del { background: var(--del-bg); color: var(--del-text); }
.dline.eq  { color: var(--eq-text); }

/* 字符级高亮（轻） */
.dline .ch-add {
  background: var(--add-strong);
  border-radius: 3px;
  padding: 1px 1px;
  font-weight: 500;
}

.dline .ch-del {
  background: var(--del-strong);
  border-radius: 3px;
  padding: 1px 1px;
  font-weight: 500;
}

.dline.placeholder { background: var(--bg-subtle); opacity: 0.5; }

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ============ 页脚 ============ */
.footer {
  text-align: center;
  padding: 20px 20px 30px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}

.footer a:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: all 220ms cubic-bezier(0.23, 1, 0.32, 1);
  pointer-events: none;
  z-index: 100;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
