:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #fbfbfa;
  --border: #e6e5e1;
  --border-strong: #d8d6d1;
  --text: #272727;
  --muted: #6f6f6b;
  --accent: #111111;
  --danger: #c84c3a;
  --warn: #9c6a10;
  --ok: #2d7a52;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
textarea {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.topbar-main {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.topbar-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.stat-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 600;
  word-break: break-word;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.meta-pill,
.tag,
.risk-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.meta-pill,
.tag {
  background: #f3f3f1;
  color: var(--muted);
  border: 1px solid #ecebe7;
}

.compare-workspace,
.workspace {
  display: grid;
  gap: 16px;
}

.compare-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}

.workspace {
  grid-template-columns: 280px minmax(0, 1fr);
  margin-top: 16px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.results {
  display: grid;
  gap: 16px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel-header.compact {
  margin-bottom: 10px;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  appearance: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button:hover {
  background: #f7f7f5;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: #222;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 14px 15px;
  line-height: 1.7;
  font-size: 14px;
}

textarea:focus {
  outline: none;
  border-color: #b8b6af;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.04);
}

.small-textarea {
  min-height: 120px;
}

.panel-footer,
.hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.summary-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

.summary-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.summary-card strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.highlight-box,
.detail-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

.highlight-box {
  min-height: 502px;
  max-height: 502px;
  overflow: auto;
  padding: 14px 15px;
  line-height: 1.85;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hit {
  border-radius: 6px;
  padding: 1px 3px;
  background: rgba(200, 76, 58, 0.15);
}

.hit.high {
  background: rgba(200, 76, 58, 0.18);
}

.hit.medium {
  background: rgba(156, 106, 16, 0.16);
}

.detail-list {
  display: grid;
  gap: 8px;
  padding: 8px;
  max-height: 520px;
  overflow: auto;
}

.detail-item,
.empty-state {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.detail-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.detail-item h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.risk-badge.high {
  background: rgba(200, 76, 58, 0.12);
  color: var(--danger);
}

.risk-badge.medium {
  background: rgba(156, 106, 16, 0.12);
  color: var(--warn);
}

.risk-badge.low {
  background: rgba(45, 122, 82, 0.12);
  color: var(--ok);
}

.detail-item p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.detail-sample {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7f7f5;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar,
  .compare-workspace,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 14px;
  }

  .topbar-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: static;
  }

  .highlight-box,
  .detail-list {
    max-height: none;
  }

  textarea,
  .highlight-box {
    min-height: 280px;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 100%);
    margin: 16px auto 24px;
  }

  .panel {
    padding: 14px;
  }

  .topbar-stats,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .panel-footer,
  .hint {
    flex-direction: column;
    align-items: stretch;
  }

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

  textarea,
  .highlight-box {
    min-height: 220px;
  }
}
