:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --high: #22c55e;
  --medium: #eab308;
  --low: #f97316;
  --unknown: #94a3b8;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #151c28 0%, var(--bg) 100%);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stats strong {
  color: var(--text);
}

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: 260px 1fr 380px;
  gap: 1rem;
  min-height: calc(100vh - 140px);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .detail {
    order: 3;
  }
}

.sidebar .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-muted {
  opacity: 0.9;
}

#search {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

#search:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip-group-vertical {
  flex-direction: column;
}

.chip-group-vertical .chip {
  width: 100%;
  text-align: left;
}

.chip-sub {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #93c5fd;
}

.doc-links {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.doc-links a {
  color: #93c5fd;
  text-decoration: none;
}

.doc-links a:hover {
  text-decoration: underline;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.source-card:hover {
  background: var(--surface-hover);
  border-color: #3d4f6a;
}

.source-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-top h3 {
  margin: 0;
  font-size: 1rem;
}

.card-top a {
  color: #93c5fd;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-type-authority {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.35);
}

.badge-type-self_media {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-trust-high { background: rgba(34, 197, 94, 0.15); color: var(--high); border-color: rgba(34, 197, 94, 0.3); }
.badge-trust-medium { background: rgba(234, 179, 8, 0.15); color: var(--medium); border-color: rgba(234, 179, 8, 0.3); }
.badge-trust-low { background: rgba(249, 115, 22, 0.15); color: var(--low); border-color: rgba(249, 115, 22, 0.3); }
.badge-trust-unknown { background: rgba(148, 163, 184, 0.15); color: var(--unknown); border-color: rgba(148, 163, 184, 0.3); }

.badge-status-verified { color: var(--high); }
.badge-status-draft { color: var(--medium); }
.badge-status-deprecated { color: var(--low); }

.card-summary {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-matrix-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.25rem;
  margin-top: 0.55rem;
}

.ai-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0;
  border-radius: 4px;
  border: 1px solid transparent;
}

.ai-cell-active {
  box-shadow: 0 0 0 1px var(--accent);
}

.matrix-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.matrix-wrap {
  overflow-x: auto;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.matrix-legend-hint {
  margin-left: auto;
}

.matrix-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 4px;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 0.25rem;
}

.ai-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.ai-matrix-table th,
.ai-matrix-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.35rem;
  text-align: center;
}

.ai-matrix-table .matrix-source {
  text-align: left;
  min-width: 140px;
  max-width: 180px;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

.matrix-ai-head {
  min-width: 52px;
  font-size: 0.72rem;
  color: var(--muted);
}

.matrix-row {
  cursor: pointer;
  transition: background 0.12s;
}

.matrix-row:hover {
  background: var(--surface-hover);
}

.matrix-row-selected {
  background: var(--accent-soft);
}

.matrix-col-active {
  background: rgba(59, 130, 246, 0.08);
}

.matrix-cell-high .matrix-dot { background: rgba(34, 197, 94, 0.2); color: var(--high); }
.matrix-cell-medium .matrix-dot { background: rgba(234, 179, 8, 0.2); color: var(--medium); }
.matrix-cell-low .matrix-dot { background: rgba(249, 115, 22, 0.2); color: var(--low); }

.ai-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.ai-detail-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.badge-trust-border-high { border-left: 3px solid var(--high); }
.badge-trust-border-medium { border-left: 3px solid var(--medium); }
.badge-trust-border-low { border-left: 3px solid var(--low); }
.badge-trust-border-unknown { border-left: 3px solid var(--unknown); }

.ai-detail-card-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ai-detail-name {
  font-size: 0.78rem;
  font-weight: 600;
}

.ai-detail-level {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.ai-detail-note {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.detail-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}

.detail-placeholder .hint {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.detail h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.detail-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.detail-meta a {
  color: #93c5fd;
}

.detail section {
  margin-bottom: 1.25rem;
}

.detail section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.detail ul, .detail ol {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.detail th, .detail td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
}

.detail th {
  background: var(--bg);
  color: var(--muted);
  width: 35%;
}

.ai-trust-table .badge {
  margin-right: 0.35rem;
  vertical-align: middle;
}

.ai-trust-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.doc-link-btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.85rem;
}

.empty {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer code {
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
