:root {
  color-scheme: dark;
  --bg: #101215;
  --panel: #191d22;
  --panel-2: #20252b;
  --line: #303741;
  --text: #f0f3f6;
  --muted: #9ca8b5;
  --accent: #2dd4bf;
  --accent-2: #f5b84b;
  --danger: #ff6b6b;
  --good: #64d58a;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(45, 212, 191, 0.12), transparent 34%),
    linear-gradient(250deg, rgba(245, 184, 75, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.toolbar,
.status-strip,
.graph-panel,
.side-panel {
  border: 1px solid var(--line);
  background: rgba(25, 29, 34, 0.92);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr minmax(190px, 260px);
  gap: 20px;
  align-items: end;
  padding: 18px;
  border-radius: 8px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #2dd4bf;
  color: #071513;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

p,
label,
.status-label {
  color: var(--muted);
}

p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.search-form {
  display: grid;
  grid-template-columns: 130px minmax(220px, 1fr) 112px 112px;
  gap: 12px;
  align-items: end;
}

.field,
.api-settings {
  display: grid;
  gap: 7px;
}

label {
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111418;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.16);
}

.primary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  height: 42px;
  background: var(--accent);
  color: #061412;
}

.secondary-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  width: 38px;
  height: 38px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.graph-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.api-settings {
  align-self: stretch;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.api-settings summary {
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr 160px 180px 150px;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 8px;
}

.trace-controls {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}

.status-label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  margin-top: 16px;
  min-height: calc(100vh - 214px);
}

.graph-panel,
.side-panel {
  min-height: 620px;
  border-radius: 8px;
  overflow: hidden;
}

.graph-panel {
  height: 796px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.flow-graph {
  position: relative;
  height: calc(100% - 76px);
  min-height: 520px;
  max-height: 720px;
  overflow: scroll;
  overscroll-behavior: contain;
  cursor: grab;
  user-select: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
}

.flow-graph.dragging {
  cursor: grabbing;
}

.flow-graph svg {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  display: block;
  flex: 0 0 auto;
}

.node-label {
  pointer-events: none;
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.node-sub {
  pointer-events: none;
  fill: var(--muted);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-node {
  cursor: copy;
}

.labeled-node circle {
  stroke-width: 3;
}

.edge-label,
.edge-time {
  fill: var(--muted);
  font-size: 10px;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.edge-label {
  fill: var(--text);
  font-weight: 700;
}

.edge-hover-label {
  opacity: 0;
  pointer-events: none;
}

.flow-edge-group:hover .edge-hover-label {
  opacity: 1;
}

.flow-graph path {
  stroke-width: 1.8;
}

.flow-edge-group,
.flow-edge,
.flow-edge-hit {
  cursor: pointer;
}

.flow-edge-group:hover .flow-edge {
  stroke-width: 3.4;
  stroke-opacity: 1;
}

.tx-list {
  height: calc(100% - 76px);
  overflow: auto;
}

.tx-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
}

.tx-card:hover {
  background: rgba(255, 255, 255, 0.035);
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.in {
  background: rgba(100, 213, 138, 0.16);
  color: var(--good);
}

.out {
  background: rgba(255, 107, 107, 0.16);
  color: var(--danger);
}

.neutral {
  background: rgba(156, 168, 181, 0.16);
  color: var(--muted);
}

.list-note {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.hash {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

.amount {
  flex: 0 0 auto;
  font-weight: 800;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  position: static;
  min-height: 180px;
}

.tx-modal[hidden] {
  display: none;
}

.tx-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.56);
}

.tx-modal-card {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tx-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.tx-modal-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.tx-detail-grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.tx-detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

.copy-text {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #111418;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: copy;
}

.modal-link {
  justify-self: start;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

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

.tx-detail-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: #111418;
}

.tx-detail-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

  .search-form {
    grid-template-columns: 1fr;
  }

  .api-settings {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
  }

  .workspace {
    min-height: auto;
  }

  .graph-panel,
  .side-panel {
    min-height: 520px;
  }
}
