:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #1f2933;
  --muted: #617080;
  --blue: #1f6feb;
  --blue-dark: #1554b3;
  --green: #2f855a;
  --amber: #b7791f;
  --red: #c53030;
  --teal: #0f766e;
  --violet: #6d28d9;
  --shadow: 0 8px 24px rgba(30, 42, 62, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.topbar-actions a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover,
.topbar-actions a:hover {
  border-color: var(--blue);
  color: var(--blue);
}

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

button.primary:hover {
  background: var(--blue-dark);
  color: #fff;
}

button.full {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 310px minmax(560px, 1fr) 390px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar,
.main-stage,
.detail-pane {
  min-width: 0;
}

.panel,
.stats-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.3;
}

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

.panel-heading h2 {
  margin: 0;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: #334155;
  font-size: 13px;
}

input[type="file"] {
  display: none;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.file-drop {
  border: 1px dashed #aab4c2;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  cursor: pointer;
}

.file-drop span {
  display: block;
  font-weight: 700;
}

.file-drop small,
.hint,
.empty {
  color: var(--muted);
  font-size: 12px;
}

.hint {
  margin: 4px 0 0;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 14px;
}

.stats-strip div {
  padding: 12px 14px;
  background: #fff;
}

.stats-strip span,
.edge-item span,
.type-item span,
.evidence-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats-strip strong,
.edge-item strong,
.type-item strong,
.evidence-item strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.4;
}

.stats-strip strong {
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e8f1ff;
  color: var(--blue-dark);
  font-size: 12px;
  white-space: nowrap;
}

.badge.ready {
  background: #e6f4ea;
  color: var(--green);
}

.badge.warn {
  background: #fff3cd;
  color: var(--amber);
}

.graph-canvas {
  min-height: 500px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfe;
}

.graph-canvas svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 500px;
}

.edge-list,
.type-summary,
.evidence-list {
  display: grid;
  gap: 8px;
}

.edge-item,
.type-item,
.evidence-item {
  padding: 9px 10px;
  border: 1px solid #edf0f5;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fbfcfe;
}

.type-item.person,
.node-person {
  border-left-color: var(--blue);
}

.type-item.place,
.node-place {
  border-left-color: var(--green);
}

.type-item.concept,
.node-concept {
  border-left-color: var(--violet);
}

.type-item.event,
.node-event {
  border-left-color: var(--amber);
}

.report-panel pre {
  margin: 0;
  min-height: 330px;
  max-height: 590px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: #fbfcfe;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 300px 1fr;
  }

  .detail-pane {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .detail-pane .panel {
    margin-bottom: 0;
  }
}

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

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

  .workspace,
  .detail-pane {
    grid-template-columns: 1fr;
  }

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