:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --border: #dfe5ef;
  --text: #1c2434;
  --muted: #5a667a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 18px 20px;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 4px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.release-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge-row.small {
  margin-top: 4px;
  font-size: 12px;
  color: #cbd5e1;
}

.badge-row .label {
  background: #2563eb;
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
}

.hidden { display: none !important; }

.auth-bar {
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  padding: 10px 20px;
}

.auth-bar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.auth-bar-inner input {
  width: 280px;
  max-width: 100%;
}

.container {
  max-width: 1320px;
  margin: 20px auto 48px;
  padding: 0 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.workspace-heading h2, #tab-intake h2 { margin-top: 0; }
#intakeForm .field, #reviewForm .field { margin-bottom: 12px; }

.reading-drawer {
  inset: 0 0 0 auto;
  width: min(100%, 46rem);
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 20px;
  border: 0;
  background: var(--card);
  color: var(--text);
  overflow: auto;
  overflow-wrap: anywhere;
}

.reading-drawer::backdrop { background: rgb(15 23 42 / 45%); }
.reading-drawer form { flex-shrink: 0; }
#readingText { white-space: pre-wrap; font: inherit; }

@media (max-width: 600px) {
  .reading-drawer { padding: 16px; }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: span 4; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}

textarea { resize: vertical; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-ghost, .chip {
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.btn-secondary:hover { background: #dbeafe; }

.btn-ghost {
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 3px 8px;
  font-size: 12px;
}

.chip-label {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

.chip {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-weight: 500;
}

.output { display: flex; flex-direction: column; gap: 12px; }

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.banner.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.banner.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}

.tag.current { background: #dcfce7; color: #166534; }
.tag.provisional { background: #fef3c7; color: #92400e; }
.tag.superseded, .tag.blocked { background: #fee2e2; color: #991b1b; }
.tag.inherited { background: #dbeafe; color: #1e40af; }

.meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

pre.markdown-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  white-space: pre-wrap;
}

/* ---------------- 全库星图样式 ---------------- */
.graph-toolbar-card {
  padding: 14px 16px;
}

.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.graph-search-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.graph-search-wrap input {
  padding-right: 84px;
}

.graph-search-status {
  position: absolute;
  right: 10px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.graph-inline-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.graph-inline-field select {
  width: auto;
  min-width: 130px;
  font-size: 13px;
  padding: 7px 10px;
}

.graph-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.graph-btn-group .btn-secondary {
  padding: 7px 11px;
  font-size: 12px;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.legend-chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.legend-chip.off {
  opacity: 0.42;
  background: #f8fafc;
  text-decoration: line-through;
}

.legend-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-chip .count {
  font-weight: 500;
  color: var(--muted);
}

.graph-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 16px;
  align-items: stretch;
}

.graph-stage {
  position: relative;
  min-height: 620px;
  height: 68vh;
  max-height: 780px;
  border-radius: 12px;
  border: 1px solid #1e293b;
  background-color: #0b1220;
  background-image: radial-gradient(rgba(148, 163, 184, 0.14) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: hidden;
}

#graphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graphCanvas.grabbing {
  cursor: grabbing;
}

#graphCanvas.pointer {
  cursor: pointer;
}

.graph-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  pointer-events: none;
  display: inline-flex;
  width: fit-content;
  max-width: calc(100% - 24px);
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  font-size: 12px;
  backdrop-filter: blur(4px);
}

.graph-hud.error {
  background: rgba(127, 29, 29, 0.92);
  border-color: #fca5a5;
  color: #fef2f2;
}

.graph-controls-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  pointer-events: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #94a3b8;
  font-size: 11px;
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.graph-drawer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: 620px;
  height: 68vh;
  max-height: 780px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.drawer-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.drawer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.drawer-back-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.drawer-back-btn:hover {
  background: #eef2f7;
}

.drawer-title-block h3 {
  margin: 0 0 6px;
  font-size: 16px;
  word-break: break-word;
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.drawer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
}

.drawer-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.drawer-statement {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.drawer-meta-grid {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 6px 8px;
  font-size: 12px;
  line-height: 1.5;
}

.drawer-meta-key {
  color: var(--muted);
  font-weight: 600;
}

.drawer-meta-val {
  color: var(--text);
  word-break: break-word;
}

.drawer-inline-link {
  border: none;
  background: #eff6ff;
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.drawer-inline-link:hover {
  background: #dbeafe;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-actions .btn-secondary {
  padding: 6px 10px;
  font-size: 12px;
}

.drawer-section {
  border-top: 1px solid #eef2f7;
  padding-top: 10px;
}

.drawer-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.rel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rel-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.rel-item:hover {
  border-color: var(--primary);
  background: #f8fbff;
}

.rel-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.rel-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 600;
}

.rel-peer-id {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.rel-peer-label {
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 960px) {
  .graph-workspace {
    grid-template-columns: 1fr;
  }
  .graph-stage {
    min-height: 460px;
    height: 56vh;
  }
  .graph-drawer {
    min-height: auto;
    height: auto;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-4 { grid-column: span 1; }
}
