:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --radius: 18px;
  --shadow: 0 18px 40px -24px rgba(17, 24, 39, .25), 0 2px 6px rgba(17, 24, 39, .04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 12% -10%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
    radial-gradient(800px 400px at 100% 0%, #ede9fe 0%, rgba(237, 233, 254, 0) 55%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 顶栏 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(229, 231, 235, .8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .01em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 8px 18px -8px rgba(67, 56, 202, .8);
}

.brand-name { font-size: 17px; }

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #eef0f7;
}

.tab {
  border: 0;
  background: transparent;
  color: #4b5563;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}

.tab:hover { color: var(--brand); }

.tab.is-active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(17, 24, 39, .08);
}

/* 主体 */
.main { flex: 1; padding-top: 36px; padding-bottom: 56px; }

.panel {
  background: var(--card);
  border: 1px solid rgba(229, 231, 235, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.panel-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -.01em;
}

.panel-head p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

/* 拖拽区 */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 28px 20px;
  border: 2px dashed #c7cbe0;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfbff, #f6f7ff);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.dropzone:hover { border-color: #a5b4fc; background: #f5f6ff; }
.dropzone:focus-visible { outline: 3px solid rgba(79, 70, 229, .25); outline-offset: 2px; }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }

.dz-icon {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
}

.dz-title { font-weight: 600; font-size: 15px; }
.dz-hint { color: var(--muted); font-size: 12.5px; }

/* 选中文件 */
.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbff;
  font-size: 14px;
}

.file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.file-size { color: var(--muted); font-size: 12.5px; }

.icon-btn {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: #eef0f7;
  color: #6b7280;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.icon-btn:hover { background: #fee2e2; color: #b91c1c; }

/* 模式选择 */
.mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.mode-label { font-size: 13.5px; color: var(--muted); font-weight: 600; }

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #eef0f7;
}

.segmented label { cursor: pointer; }

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented span {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: #4b5563;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 6px rgba(17, 24, 39, .08);
}

.segmented input:focus-visible + span { outline: 3px solid rgba(79, 70, 229, .25); }

/* 按钮 */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 22px;
  padding: 13px 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 14px 24px -14px rgba(67, 56, 202, .9);
  transition: filter .18s ease, transform .18s ease, opacity .18s ease;
}

.primary-btn:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: translateY(0); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.primary-btn.is-disabled { opacity: .55; pointer-events: none; }

.primary-btn.small {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
  font-size: 14px;
  flex: none;
}

/* 提示与进度 */
.notice {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
}

.notice.error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.progress-card {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbff;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
}

#convert-elapsed { color: var(--muted); font-variant-numeric: tabular-nums; }

.progress-track {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e8eaf3;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #4f46e5);
  transition: width .4s ease;
}

.progress-track.indeterminate .progress-bar {
  width: 38%;
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}

.progress-tip { margin-top: 10px; color: var(--muted); font-size: 12.5px; }

/* 结果 */
.result-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  background: var(--ok-soft);
}

.result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-weight: 800;
  flex: none;
}

.result-main { min-width: 0; }
.result-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { color: #4b5563; font-size: 12.5px; }

.footnote {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

/* 比对输入 */
.diff-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mini-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 150px;
  padding: 20px 16px;
  border: 2px dashed #c7cbe0;
  border-radius: 14px;
  background: #fbfbff;
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease;
}

.mini-drop:hover { border-color: #a5b4fc; }
.mini-drop:focus-visible { outline: 3px solid rgba(79, 70, 229, .25); outline-offset: 2px; }
.mini-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }

.slot-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.slot-file {
  max-width: 100%;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 比对结果 */
.diff-result {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #fafbff;
  border-bottom: 1px solid var(--line);
}

.diff-stats { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}

.chip-del { background: var(--danger-soft); color: #991b1b; }
.chip-ins { background: var(--ok-soft); color: #166534; }
.chip-chg { background: #fffbeb; color: #92400e; }

.view-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: #eef0f7;
}

.view-btn {
  border: 0;
  background: transparent;
  color: #4b5563;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.view-btn.is-active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(17, 24, 39, .08);
}

.diff-legend {
  display: flex;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.lg { display: inline-flex; align-items: center; gap: 6px; }

.lg::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.lg-del::before { background: #fca5a5; }
.lg-ins::before { background: #86efac; }
.lg-same::before { background: #e5e7eb; }

.diff-body {
  max-height: 560px;
  overflow: auto;
  font-size: 13.5px;
  line-height: 1.65;
}

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

.drow { display: contents; }

.dcell {
  padding: 7px 12px;
  border-bottom: 1px solid #f1f2f7;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 36px;
}

.dcell.left { border-right: 1px solid #f1f2f7; }
.dcell.same { color: #374151; }
.dcell.split .none { color: #c0c4d0; }

.none { color: #c0c4d0; font-style: italic; }

.diff-body.split .dcell:nth-child(odd) { background: #fcfcfe; }

/* 差异高亮 */
span.d {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 3px;
  padding: 0 1px;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

span.i {
  background: #dcfce7;
  color: #166534;
  border-radius: 3px;
  padding: 0 1px;
}

.diff-body.stack { display: block; }

.srow {
  padding: 7px 14px;
  border-bottom: 1px solid #f1f2f7;
  white-space: pre-wrap;
  word-break: break-word;
}

.srow.same { color: #374151; }
.srow.del { background: #fff5f5; border-left: 3px solid #f87171; color: #7f1d1d; }
.srow.ins { background: #f2fdf6; border-left: 3px solid #34d399; color: #064e3b; }

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

/* 页脚 */
.site-footer {
  border-top: 1px solid rgba(229, 231, 235, .9);
  background: rgba(255, 255, 255, .7);
}

.footer-inner {
  padding-top: 22px;
  padding-bottom: 26px;
  text-align: center;
}

.footer-stats { margin: 0; font-size: 13.5px; color: #374151; }
.footer-meta { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.footer-quota { margin: 6px 0 0; font-size: 12px; color: #9ca3af; }
.footer-beian { margin: 10px 0 0; font-size: 12px; }
.footer-beian a { color: #9ca3af; text-decoration: none; }
.footer-beian a:hover { color: var(--brand); text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 460px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(17, 24, 39, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 16px 30px -16px rgba(0, 0, 0, .6);
}

@media (max-width: 720px) {
  .main { padding-top: 22px; padding-bottom: 36px; }
  .panel { padding: 22px 18px; border-radius: 16px; }
  .panel-head h1 { font-size: 21px; }
  .header-inner { min-height: 58px; }
  .brand-name { display: none; }
  .tab { padding: 7px 12px; font-size: 13px; }
  .diff-inputs { grid-template-columns: 1fr; }
  .diff-body.split { grid-template-columns: 1fr; }
  .dcell.left { border-right: 0; }
  .dcell.left:not(.same) { border-bottom: 1px dashed #f1f2f7; }
  .result-card { flex-wrap: wrap; }
  .result-main { flex: 1 1 100%; }
  .primary-btn.small { width: 100%; }
  .dropzone { min-height: 160px; padding: 22px 14px; }
  .footer-stats { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
