:root {
  --bg: #f5f1ea;
  --panel: #fffdf8;
  --ink: #1f2528;
  --muted: #6b7278;
  --line: #d9d0c4;
  --accent: #0e6674;
  --accent-ink: #073b44;
  --accent-bg: #dff2f4;
  --old: #aa271b;
  --old-bg: #ffe5df;
  --new: #087443;
  --new-bg: #ddf6e8;
  --warn: #7a570f;
  --warn-bg: #fff1c2;
  --shadow: 0 18px 42px rgba(48, 39, 25, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(14, 102, 116, 0.07), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 234, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.25;
}

.status-pill {
  min-width: 104px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.workbench,
.summary,
.empty-state,
.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workbench {
  padding: 16px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dropzone {
  display: grid;
  gap: 8px;
  min-height: 132px;
  border: 1px dashed #b6a999;
  border-radius: 8px;
  padding: 16px;
  background: #fbf8f1;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.dropzone:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #fffaf0;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.dropzone strong {
  align-self: center;
  font-size: 20px;
  line-height: 1.35;
  word-break: break-word;
}

.dropzone small {
  color: var(--muted);
  font-size: 13px;
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions {
  margin-top: 14px;
}

button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.ghost,
.chip {
  border-color: var(--line);
  background: #fffaf0;
  color: var(--ink);
}

.mini {
  min-height: 30px;
  margin-top: 8px;
  padding: 0 10px;
  font-size: 12px;
}

.chip {
  min-height: 34px;
  border-radius: 999px;
  font-size: 13px;
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 800;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  background: var(--line);
}

.metric {
  background: var(--panel);
  padding: 16px;
}

.metric b {
  display: block;
  font-size: 24px;
  line-height: 1.15;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  margin: 14px 0;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 48px 24px;
  text-align: center;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 900;
}

.empty-state p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.8;
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.record {
  overflow: hidden;
}

.record-head {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: #fbf7ef;
}

.rid {
  color: var(--accent);
  font-weight: 900;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ece6dc;
  color: #3c4245;
  font-size: 12px;
}

.tag.high {
  background: #ffe1db;
  color: #8f1d14;
}

.tag.medium {
  background: var(--warn-bg);
  color: var(--warn);
}

.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.loc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: right;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.side {
  min-width: 0;
  padding: 15px;
}

.side + .side {
  border-left: 1px solid var(--line);
}

.side h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.text-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

.fragment-list {
  display: grid;
  gap: 8px;
  white-space: normal;
}

.fragment {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.fragment-old {
  border-color: #f3c7bf;
  background: var(--old-bg);
  color: #7d1f16;
}

.fragment-new {
  border-color: #b9ead0;
  background: var(--new-bg);
  color: #075e38;
}

mark {
  border-radius: 3px;
  padding: 1px 2px;
}

.mark-old {
  background: var(--old-bg);
  color: var(--old);
  text-decoration: line-through;
}

.mark-new {
  background: var(--new-bg);
  color: var(--new);
}

.empty-text {
  color: var(--muted);
  font-style: italic;
}

.annotation-panel {
  border-top: 1px solid var(--line);
  background: #f8f4ed;
  padding: 14px;
}

.pdf-annotation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pdf-annotation-side {
  min-width: 0;
}

.pdf-annotation-side h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.pdf-pages {
  display: grid;
  gap: 12px;
}

.pdf-page-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.pdf-page-label {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pdf-page-wrap {
  position: relative;
  max-width: 100%;
  overflow: auto;
  background: #d9d0c4;
}

.pdf-page-wrap canvas {
  display: block;
  background: #fff;
}

.pdf-mark {
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 4px;
  pointer-events: auto;
  mix-blend-mode: multiply;
}

.pdf-mark-old {
  background: rgba(255, 84, 60, 0.24);
  color: #b02b1f;
}

.pdf-mark-new {
  background: rgba(42, 184, 111, 0.24);
  color: #087443;
}

.pdf-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    padding: 14px;
  }

  .upload-grid,
  .summary,
  .compare,
  .pdf-annotation-grid {
    grid-template-columns: 1fr;
  }

  .record-head {
    grid-template-columns: 1fr;
  }

  .loc {
    text-align: left;
  }

  .side + .side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
